GenuineSounds

Recursion Help

Jul 25th, 2011
250
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. public class Recurse
  2. {
  3.     public static void main(String[] args)
  4.     {
  5.         int in = 50;
  6.         double out = factorial(in);
  7.        
  8.         for(int x = 1; x<in ; x++)
  9.         {
  10.             out = factorial(x);
  11.             System.out.println(x+" factorial equals "+out);
  12.         }
  13.     }
  14.    
  15.     public static double factorial(int n)
  16.     {
  17.         double fact = 1;
  18.         for(int i = 1; i<=n ; i++)
  19.         {
  20.             fact=fact*i;
  21.         }
  22.         return fact;
  23.     }
  24. }
Advertisement
Comments
  • User was banned
Add Comment
Please, Sign In to add comment