Sum of the digits of 1729!

Find the sum of digits of the decimal representation of 1 × 2 × × 1729 1\times2\times\cdots \times1729 .


The answer is 19863.

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

1 solution

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
import java.math.BigInteger;

public class main {
    public static void main( String[] args) {
        BigInteger sum = BigInteger.valueOf(0);
        BigInteger fact = BigInteger.valueOf(1729);
        BigInteger temp = BigInteger.valueOf(0);
        for (int i = 1729; i > 1; i--) {
            fact = fact.multiply(BigInteger.valueOf(i));
        }
        while (!fact.equals(BigInteger.ZERO)){
            sum = sum.add(fact.mod(BigInteger.valueOf(10)));
            fact = fact.divide(BigInteger.valueOf(10));
            System.out.println(sum + " "+ fact);
        }
         System.out.println(sum);
    }
}

I hope no can is going to solve this using Mathematics

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...