Java program to find factorial of large number

Factorial of large number

  • This program shows the concept to find factorial of large number.As it is not possible for simple datatype to store more than 100’s of digit.Integer and long are note able to store such a long numbers.
  • To store large numbers of digits java introduce a new class called import java.math.BigIntege.This class helps to store large number of digits.
  • So it is easy to find factorial of large number using this class.Users can not use a * operator to multiply two numbers.
  • multiply keyword is used to multiply two numbers.

  • Working of program

  • We have made a object b1 of class BigInteger.
  • “b1” will store a factorial of a input number.
  • BigInteger.valueOf(i) will convert the “int” value into “BigInteger”.
  • b1.multiply(BigInteger.valueOf(i)) is used to multiply the value of “i” with “b1”.

import java.util.*;
import java.math.BigInteger;
class scan
{
	 public static void main(String arg[])
	 {
		 BigInteger b1=new BigInteger("1");
 int i,y;

Scanner kb=new Scanner(System.in);
 System.out.println("Enter number to find factorial:- ");
y=kb.nextInt();

for(i=2;i<=y;i++)
{
	b1 = b1.multiply(BigInteger.valueOf(i));
}
System.out.println(b1);
}
}

OUTPUT:-

factorial of large number


What if we use a * operator?

As in a picture we can see that program will give error of “operator * cannot applied to import java.math.BigInteger”.

Factorial of large number


Comment below if you are facing any problem .

Also read:-

Java program to find a table of a input number using for loop
Java Program to check Input number is Palindrome or not

52 comments on “Java program to find factorial of large number

  1. Jack

    Ꭲhese are reɑⅼly fantastic ideas in regarding bloging.
    You have touchеd some good points here. Any way keep up writing.

    Reply
  2. blogs

    Tremendous things here. I’m very happy to see your article.
    Thank you a lot and I am having a look forward to touch you.
    Will you please drop me a e-mail?

    Reply
  3. Barbara Mori

    Excellent article. Keep writing such kind of information on your site.
    Im really impressed by it.
    Hi there, You have done a great job. I will certainly digg
    it and in my opinion recommend to my friends.

    I am confident they will be benefited from this
    site.

    Reply
  4. asian dating

    Very nice post. I just stumbled upon your weblog and wanted to say that I
    have truly enjoyed surfing around your blog posts. After all
    I will be subscribing to your rss feed and I hope you write again very soon!

    Reply
  5. Delhi Porn

    Simply desire to say your article is as amazing. The clearness for your submit is simply excellent and i could assume you are knowledgeable on this subject.
    Fine together with your permission allow me to grasp your
    feed to stay up to date with imminent post.
    Thank you 1,000,000 and please carry on the enjoyable work.

    Reply
  6. game

    I got this site from my pal who told me about this site and now this time I am
    visiting this site and reading very informative content at this place.

    Reply
  7. obat penumbuh rambut

    Howdy outstanding website! Does running a blog similar
    to this require a great deal of work? I have no expertise in coding
    however I was hoping to start my own blog in the near future.

    Anyhow, if you have any ideas or tips for new blog owners please share.

    I understand this is off topic however I just had to
    ask. Appreciate it!

    Reply
  8. escort balıkesir

    I am curious to find out what blog platform you
    have been using? I’m experiencing some minor security issues with my latest site and I’d like to
    find something more safeguarded. Do you have any suggestions?

    Reply
  9. estate planning services whittier

    An outstanding share! I’ve just forwarded this onto a colleague who had been doing a little research on this.
    And he actually ordered me breakfast simply because I discovered it for him…
    lol. So let me reword this…. Thanks for the
    meal!! But yeah, thanks for spending some time to talk about this subject here
    on your web page.

    Reply
  10. netflix france

    Normally I don’t read article on blogs, but I would like to say that this write-up very
    forced me to check out and do it! Your writing taste has been surprised me.
    Thank you, very great article.

    Reply
  11. researchave

    Thanks on your marvelous posting! I truly enjoyed reading it, you are a great author.I will ensure that I
    bookmark your blog and may come back at some point.
    I want to encourage you continue your great posts, have a nice evening!

    Reply
  12. repair required

    Hey excellent blog! Does running a blog like this take a massive amount work?
    I have very little knowledge of computer programming
    however I had been hoping to start my own blog soon.
    Anyways, should you have any ideas or techniques for new blog owners please share.
    I know this is off subject however I just needed to ask.
    Thank you!

    Reply
  13. barcos

    It’s perfect time to make some plans for the future and it is time
    to be happy. I’ve read this post and if I could I wish to suggest you some interesting things or suggestions.
    Maybe you could write next articles referring to this article.
    I desire to read more things about it!

    Reply
  14. keo bet

    I’m not sure where you are getting your information, but great topic.
    I needs to spend some time learning more or understanding more.

    Thanks for excellent information I was looking for this info
    for my mission.

    Reply
  15. opview

    whoah this blog is excellent i like studying your posts.
    Keep up the great work! You recognize, lots of persons
    are searching round for this information, you could help them
    greatly.

    Reply
  16. broderie

    We’re a group of volunteers and starting a new scheme in our community.
    Your site provided us with valuable info to work on. You’ve done an impressive
    job and our whole community will be thankful to you.

    Reply
  17. M88

    I have read so many articles or reviews concerning the blogger lovers except this paragraph is truly a fastidious
    post, keep it up.

    Reply
  18. paul

    Generally I do not learn article on blogs, however
    I wish to say that this write-up very forced me to take a look at and do it!

    Your writing taste has been surprised me. Thank you, very great article.

    Reply
  19. one click root towelroot

    Thanks a lot for sharing this with all folks you actually understand
    what you’re speaking approximately! Bookmarked. Plwase additionally seek advice from my website =).
    We mayy have a linnk exchange contract among us

    Reply
  20. blogtrigger

    Wonderful items from you, man. I’ve remember your stuff prior to and you’re just extremely excellent.
    I actually like what you’ve got right here, certainly like what you’re stating
    and the best way in which you say it. You’re making it entertaining and you continue to take
    care of to stay it smart. I can not wait to learn much more from you.

    That is actually a great website.

    Reply
  21. bitcoin generator freeware

    Excellent blog right here! Additionally your web site so much up fast!
    What web host are you the use of? Can I am getting your associate link
    in your host? I want my website loaded up as quickly as
    yours lol

    Reply
  22. russian

    Hеllo! I just would likе to give you a Һuge thumbs սp for yoսr
    excellent info уоu have here ߋn thіѕ post.
    I ɑm comіng bzck to your blog for mre soon.

    Reply
  23. clash royale hack

    Fantastic goods from you, man. I’ve understand your stuff previous to and you are just extremely excellent.
    I actually like what you’ve acquired here,
    certainly like what you are saying and the way in which you say it.
    You make it enjoyable and you still care for to
    keep it sensible. I can not wait to read much more from you.

    This is really a tremendous website.

    Reply
  24. electric

    wonderful post, very informative. I wonder why the other
    experts of this sector do not realize this. You must continue your writing.
    I’m sure, you have a great readers’ base already!

    Reply
  25. killer clown video

    Nice post. I was checking continuously this blog and I am impressed!

    Extremely useful info specially the last part 🙂 I care
    for such info much. I was seeking this particular information for a very long time.

    Thank you and good luck.

    Reply

Leave a Reply

Your email address will not be published. Required fields are marked *