Skip to main content

Posts

Showing posts from September, 2016
16) Problem 16- Project Euler Solution in Java 2 15 = 32768 and the sum of its digits is 3 + 2 + 7 + 6 + 8 = 26. What is the sum of the digits of the number 2 1000 ? Using the BigInteger() class :         int sum =0;         BigInteger big = new BigInteger("2");         big = big.pow(1000);         String result =big.toString();         for(int i=0;i<result.length();i++){             sum+=Character.getNumericValue(result.charAt(i));         }         System.out.println("sum : "+sum );