Advertisement
Codex

Factorial

Jul 1st, 2011
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.47 KB | None | 0 0
  1. /*This program finds factorial of given no. */
  2.  
  3. import java.util.Scanner;
  4. class Factorial
  5. {
  6.  
  7.       public static void main(String args[])
  8.       {
  9.          Scanner sc=new Scanner(System.in);
  10.           int num = sc.nextInt();          
  11.           int result = 1;
  12.  
  13.           while(num>0)
  14.           {
  15.  
  16.                 result = result * num;
  17.  
  18.                 num--;
  19.  
  20.           }
  21.  
  22.           System.out.println("Factorial of Given no. is : "+result);
  23.  
  24.      }
  25.  
  26. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement