Results 1 to 3 of 3
  1. #1
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default Digit sum of extremely large numbers

    I figured it out, can't figure out how to delete it, sorry to make a post about nothing.
    Last edited by sunde887; 01-26-2011 at 09:08 PM.

  2. #2
    pbrockway2 is offline Moderator
    Join Date
    Feb 2009
    Location
    New Zealand
    Posts
    4,565
    Rep Power
    12

    Default

    Roughly speaking n(n+1) will have twice as many digits as n and the resulting exponential growth of the digit length of n! is going to be a problem sooner or later.

    Perhaps some number theory is called for.

    Some people make a distinction between digit sums and reduced digit sums (ie 456->15 vs 456->6): which do you mean?

    [Edit] The question was to find the digit sum of 50000!
    Last edited by pbrockway2; 01-26-2011 at 10:55 PM.

  3. #3
    sunde887's Avatar
    sunde887 is offline Moderator
    Join Date
    Jan 2011
    Location
    Richmond, Virginia
    Posts
    3,069
    Blog Entries
    3
    Rep Power
    8

    Default

    I ended up figuring it out by using big int to string method differently, then I just looped through the produced string, changing each item to an int with parseInt, and finally adding it to sum.

Similar Threads

  1. Getting rid of commas in large numbers?
    By wwuster in forum Advanced Java
    Replies: 12
    Last Post: 03-05-2012, 10:35 AM
  2. inputting large numbers into java
    By imorio in forum New To Java
    Replies: 9
    Last Post: 12-26-2010, 01:59 PM
  3. Math problem Sum of a hundred 50 digit numbers.
    By AcousticBruce in forum New To Java
    Replies: 13
    Last Post: 12-19-2010, 01:36 PM
  4. crunching large numbers
    By aaroncarpet in forum Advanced Java
    Replies: 26
    Last Post: 11-30-2009, 02:10 AM
  5. Crunching large numbers part II
    By aaroncarpet in forum Advanced Java
    Replies: 0
    Last Post: 11-28-2009, 05:34 AM

Posting Permissions

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