Tuesday, April 16, 2013

Selenium :To find Factorial of a number



To find Factorial of a number



import javax.swing.JOptionPane;
public class Factorial
{
 public static void main(String[] args)
 {
  int iRes=1;
  String sPict="1";
  int ifact=Integer.parseInt(JOptionPane.showInputDialog("enter an integer"));

  for (int i=2 ; i<=ifact ; i++)
  {
   iRes=iRes*i;
   sPict=i+"x"+sPict;
  
  }
  System.out.println(sPict+"="+iRes); 
 }
}

No comments:

Post a Comment