Is it a joke

Find sum of digits of 6 2014 {6^{2014}}


The answer is 6939.

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.

3 solutions

Brian Brooks
Dec 31, 2014

Python (among many other languages) has native support for large integers, which is handy for working with 6**2014. A simple function can be used to accumulate the right-most digit and chop it off, rinse and repeat.

def go(n):
    ans = 0
    while (n > 0):
        ans = ans + n % 10
        n = n / 10
    return ans

go(6**2014)
Sung Moo Hong
Dec 19, 2014

Using Common Lisp

>(defun sum-digits (number base) (loop for n = number then q for (q r) = (multiple-value-list (truncate n base)) sum r until (zerop q)))

>(sum-digits (expt 6 2014) 10)

reference site : http://rosettacode.org/wiki/Sum digits of an integer

Written in C#:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
using System;
using System.Numerics;

public class Program
{
    public static void Main()
    {
        System.Numerics.BigInteger i = BigInteger.Pow(6, 2014);
        Console.WriteLine(DigitSum(i));
    }

    static int DigitSum(BigInteger n)
    {
        int sum = 0;

        while (n != 0)
        {
            sum += (int)(n % 10);
            n /= 10;
        }

        return sum;
    }
}

Can anyone post the solution in classical method - without any computer programme? Thanks.

Prabir Chaudhuri - 6 years, 5 months ago

Log in to reply

I think there is no general equation to get a digit sum.

Sung Moo Hong - 6 years, 5 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...