Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class ls {
- public static void main(String[]args){
- Scanner kb = new Scanner(System.in);
- int n, sum=1, dnum;
- System.out.println("enter your number to be factored");
- n = kb.nextInt();
- dnum = n;
- while(n >=1){
- sum = sum * n;
- n--;
- }
- System.out.print("The factorial of "+dnum+ " is "+sum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement