How to work with numbers of the order 10^100?Like iterating upto a number of that order,getting sum of squares of their digits;then checking if the sum matches the square of a certain number,if yes sum up those numbers and finally display the sum of those numbers.
            Asked
            
        
        
            Active
            
        
            Viewed 65 times
        
    -2
            
            
        - 
                    5Java has a class called `BigInteger`. – Dawood ibn Kareem Jan 25 '17 at 21:21
- 
                    Iterating up to 10^100? Even if iteration is taking 1nSec, it will be 10^91 seconds. about 10^86 years.. Hm. – Eugene Sh. Jan 25 '17 at 21:23
- 
                    You can't iterate to a number that large, you have to use a formula which calculates the result in a reasonable amount of time. – Peter Lawrey Jan 25 '17 at 21:34
1 Answers
0
            
            
        You can easily handle this kind of task with strings containing the decimal representation of the numbers.
The sum of squares of the digits of a 100 digit number is bounded by 100*9^2 = 8100: you can use int for that.
 
    
    
        chqrlie
        
- 131,814
- 10
- 121
- 189
- 
                    It will take longer than the age of the universe to iterate to that number however ;) – Peter Lawrey Jan 25 '17 at 21:35
- 
                    
- 
                    @PeterLawrey: It actually depends how the iteration is performed: if large chunks are skipped at a time, it may bring it down to a more manageable timeframe. – chqrlie Jan 25 '17 at 22:32
