1
resposta

[Projeto] Desafio: Fatorial

public class Fatorial {
    public static void main(String[] args) {
        for(int n = 1;n<=10;n++) {
            int fatorial =1;
            for(int i=n;i>0;i--) {
                fatorial*=i;
                if(i==1) {
                    System.out.println("O fatorial de (" + n +"!) é: " + fatorial);
                    break;
                }
            }
        }
    }
}

Garanta sua matrícula hoje e ganhe + 2 meses grátis

Continue sua jornada tech com ainda mais tempo para aprender e evoluir

Quero aproveitar agora
1 resposta

Muito bom Rafael :)