Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class FactorialCalculation {
- public static void main(String[] args) {
- Scanner sc = new Scanner(System.in);
- System.out.print("Enter a number: ");
- int z = 0;
- int n = sc.nextInt();
- z = n;
- long factorial = 1;
- for (int i = 1; i <= n; n--) {
- factorial *= n;
- }
- System.out.println("The factorial of " + z + " is: " + factorial);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement