Team-ClanX.org Forum Index Team-ClanX.org
Web Board for the ClanX Team
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in    Return homeReturn Home 

Factorial Class

 
Post new topic   Reply to topic    Team-ClanX.org Forum Index -> Java
View previous topic :: View next topic  
Author Message
Opposite^Force
Super scripter


Joined: 12 Aug 2004
Posts: 172
Location: Turkey, Istanbul

PostPosted: Fri Nov 16, 2007 3:24 am    Post subject: Factorial Class Reply with quote

Code:

class Factorial {

   public static long m;

   public static long f;

   public static long Factorial() {

      return 0;

   }

   public static long Calc(int n) {

      if (n > 0) {

         long i = 1;

         f = 1;

         while (++i <= n) {

            f *= i;

         }

         m = f;

      }

      if (n == 0) { m = 1; }

      return m;

   }

}


example code..

Code:

public class FT {
   
   public static void main(String[] args) {
      
      Factorial a = new Factorial();
   
      System.out.println(a.Calc(5));
      
   }
   
}

_________________
Opposite^Force
Team Clan X Scripter
Email: oscripts@aa-labs.com
Back to top
View user's profile Send private message Send e-mail MSN Messenger
Display posts from previous:   
Post new topic   Reply to topic    Team-ClanX.org Forum Index -> Java All times are GMT - 7 Hours
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group