blahs44

Untitled

Oct 20th, 2013
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. import java.io.*;
  2.  
  3. public class AAAA {
  4.    
  5.     public static void main(String args[]) {
  6.         String str;
  7.         int no, fact;
  8.         fact = 1;
  9.  
  10.         try {
  11.             BufferedReader obj = new BufferedReader(new InputStreamReader(
  12.                     System.in));
  13.             System.out.print("Enter number whose Factorial is to be found : ");
  14.             System.out.flush();
  15.             str = obj.readLine();
  16.             no = Integer.parseInt(str);
  17.  
  18.             while (no > 0) {
  19.                 fact = fact * no;
  20.                 no = no - 1;
  21.             }
  22.  
  23.             System.out.println("FACTORIAL of a given number is  :  " + fact);
  24.         } catch (Exception e) {
  25.         }
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment