Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String args[]) {
- Scanner scanner = new Scanner(System.in);
- int number;
- System.out.println("Enter a Number:");
- number = scanner.nextInt();
- System.out.println(number + "! = " + calcFact(number));
- }
- static int calcFact(int number) {
- int j = 1;
- for (int i = 1; i <= number; i++) {
- j *= i;
- }
- return j;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment