+ Reply to Thread
Results 1 to 1 of 1

Thread: Working with huge numbers

  1. #1
    Chinmoy's Avatar
    Chinmoy is offline Programming Expert
    Join Date
    Feb 2008
    Location
    where heaven meets earth
    Posts
    410
    Rep Power
    18

    Working with huge numbers

    The number is really big!!
    Sometimes we find it out of capabilities for languages to work with huge numbers. In java we have a class which can work with any size of an integer.

    Here i have implemented a factorial with the same. The logic is the same as for finding factorials. The code goes as follows ::

    Code:
    import java.math.BigInteger;
    import java.lang.*;
    import java.util.Scanner;
    class largenumber
    {
    public static void main(String args[])
    {
    Scanner in=new Scanner(System.in);
    System.out.println("Enter a number for factorial");
    int num=in.nextInt();
    BigInteger fact=BigInteger.valueOf(1);
    for(int i=2;i<=num;i++)
    {
    fact=fact.multiply(BigInteger.valueOf(i));
    }
    System.out.println("Factorial "+num+" is ::\n\t"+fact);
    }
    }
    Read further here :: 25 factorial | TECHARRAZ
    Last edited by Chinmoy; 06-11-2008 at 05:54 AM.
    God is real... unless declared an integer

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Location
    Advertising world
    Posts
    Many

     
+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 20
    Last Post: 01-30-2011, 11:40 PM
  2. Intermediate Addition with extremely huge numbers in C++
    By Csabi in forum C Tutorials
    Replies: 0
    Last Post: 01-30-2011, 02:21 AM
  3. Creating a huge file filled with numbers.
    By Paradox in forum Java Tutorials
    Replies: 2
    Last Post: 07-17-2008, 01:48 PM
  4. Huge Small File
    By John in forum General Programming
    Replies: 4
    Last Post: 03-27-2008, 11:14 PM
  5. HUGE Problem! Please help!
    By tyr in forum General Programming
    Replies: 1
    Last Post: 07-31-2007, 09:24 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts