Skip to content

Instantly share code, notes, and snippets.

@jimywork
Last active August 22, 2017 16:10
Show Gist options
  • Save jimywork/9c3d64df8d81a01e08ec7e427808cb28 to your computer and use it in GitHub Desktop.
Save jimywork/9c3d64df8d81a01e08ec7e427808cb28 to your computer and use it in GitHub Desktop.
Lista de Exercícios Java
// Faça um programa que leia um número N e que indique quantos valores inteiros e positivos devem ser lidos a seguir.
// Para cada número lido, mostre uma tabela contendo o valor lido e o fatorial desse valor.
import java.util.Scanner;
class Main {
public static void main(String[] args) {
int n;
int fatorial = 1;
Scanner scanner = new Scanner(System.in);
System.out.print("Digite um numero:");
n = scanner.nextInt();
System.out.printf("%d serão lidos a seguir \n", n);
for(int i = 1; i <= n; i++) {
fatorial = fatorial * i;
System.out.printf("Fatorial de %d é %d\n", i, fatorial);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment