class FatorialDemo {
	public int fatorial (int n){
		if (n==1) {
			return 1;		
		} 
		/* Definicao recursiva, invoca a si mesmo */ 
		return fatorial(n-1)*n;
	}

	public static void main(String args[]) {
		FatorialDemo teste = new FatorialDemo();
		System.out.println(teste.fatorial(5));
	}
}
Este artigo foi útil ?
SimNão

3 Replies to “(Recursividade) – Exemplo fatorial”

  1. jili178casino disse:

    Jili178casino, now we’re talking! Time to hit the tables or spin the reels. Big wins incoming! What are you waiting for? Sign up here jili178casino

  2. 500jlcasino disse:

    500jlcasino has been a steady experience. Offers many perks to new players. You can join up over at 500jlcasino.

  3. stargame disse:

    Stargame, yeah? Seems like a solid option. Pretty standard fare, but hey, sometimes that’s all you need. If you ain’t got anything else going on, stargame might just scratch that itch.

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

Close Search Window