Last active
August 22, 2017 16:10
-
-
Save jimywork/9c3d64df8d81a01e08ec7e427808cb28 to your computer and use it in GitHub Desktop.
Lista de Exercícios Java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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