The First Easy Number Game

How many 3-digit numbers satisfy:

a b c = a 3 + b 3 + c 3 \overline { abc } =\quad { a }^{ 3 }+{ b }^{ 3 }+{ c }^{ 3 }


The answer is 4.

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.

9 solutions

Chew-Seong Cheong
Jan 19, 2015

Let me explain this logically.

We note that the RHS can only come from the sum of three cubes, which are:

0 3 = 0 1 3 = 1 2 3 = 8 3 3 = 27 4 3 = 64 5 3 = 125 6 3 = 216 7 3 = 343 8 3 = 512 9 3 = 729 \begin{matrix} 0^3 = 0 & 1^3 =1 & 2^3 =8 & 3^3 =27 & 4^3 =64 \\ 5^3 =125 & 6^3 =216& 7^3 =343 & 8^3 =512 & 9^3 =729 & \end{matrix}

If a = 1 100 < a=1\quad \Rightarrow 100< RHS < 200 <200 and the possible solutions are:

105 = 1 + 0 + 125 126 \overline{105}=1+0+125\ne126

115 = 1 + 1 + 125 127 \overline{115}=1+1+125\ne127

125 = 1 + 8 + 125 134 \overline{125}=1+8+125\ne134

135 = 1 + 27 + 125 153 \overline{135}=1+27+125\ne153

144 = 1 + 64 + 64 129 \overline{144}=1+64+64\ne129

150 = 1 + 125 + 0 126 \overline{150}=1+125+0\ne126

151 = 1 + 125 + 1 127 \overline{151}=1+125+1\ne127

152 = 1 + 125 + 8 134 \overline{152}=1+125+8\ne134

153 = 1 + 125 + 27 = 153 \overline{153}=1+125+27 = 153 \leftarrow acceptable solution

154 = 1 + 125 + 64 190 \overline{154}=1+125+64\ne190

Similarly, the other solutions are: 370 370 , 371 371 and 407 407 .

Bill Bell
Jul 14, 2015

000 and 001 not inclusive.

Lu Chee Ket - 5 years, 6 months ago

Log in to reply

I'm not clear about what you mean. Notice that the loop involving s goes from 100 through 999 inclusive.

Bill Bell - 5 years, 6 months ago

Log in to reply

Very often I see that the front digit(s) of zero(es) is (are) not inclusive in brilliant. Just like to take note of these.

Lu Chee Ket - 5 years, 6 months ago

Log in to reply

@Lu Chee Ket Yes, it would have been easy to have made that mistake.

Bill Bell - 5 years, 6 months ago

Log in to reply

@Bill Bell Not a mistake to me but whether how we like to take.

Lu Chee Ket - 5 years, 6 months ago
Dalia Palace
Aug 14, 2015

My python solution:

 l = []

 for i in range(100, 1000):

m = str(i)

if i == (int(m[0])**3 + int(m[1])**3 + int(m[2])**3):

    l.append(i)

  len(l)

 Result: 4
David Holcer
Mar 21, 2015
1
2
3
4
5
6
counter=0
for i in range(10**2,10**3):
    i=str(i)
    if int(i[0])**3+int(i[1])**3+int(i[2])**3==int(i):
        counter+=1
print counter

Brock Brown
Feb 24, 2015

Python:

1
2
3
4
5
6
count = 0
for test in xrange(100,1000):
    a, b, c = [int(n) for n in str(test)]
    if test == a**3 + b**3 + c**3:
        count += 1
print "Answer:", count

Venkatachalam J
Dec 16, 2016

An Armstrong number is an n-digit number that is equal to the sum of the nth powers of its digits.

Armstrong numbers of order three is 153, 370. 371, 407 respectively.

(An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself)

Hence the solution is 4.

Bob Kadylo
Nov 10, 2015

I used 'BASIC'

10 for n=100 to 999

20 n$=str$(n)

30 a=val(left$(n$,1))

40 b=val(mid$(n$,2,1))

50 c=val(right$(n$,1))

60 if a^3+b^3+c^3=n then cnt=cnt+1:print n,cnt

70 next n

80 print "Done !!"

OUTPUT

153 1

370 2

371 3

407 4

Done !!

This program would run on many 8-bit computers from the '70's and '80's Apple II,+,e,c Commodore PET, VIC20, C64 (I have all of them in my museum) It runs on my PC, as is, using " Just Basic " but it doesn't need line numbers.

Moderator note:

Since there are finitely many cases, we could check every single case and arrive at the answer.

My Solution in C++

include<bits/stdc++.h>

using namespace std;

int main()

{

int cnt=0;

for(int i=100; i<1000; i++)

{

    int a=i;

    int c=a%10;

    a/=10;

    int b=a%10;

    a/=10;

    if(i==(a*a*a + b*b*b + c*c*c))    

   cnt++;

}

cout<<cnt<<endl;

return 0;

}

Rayyan Shahid
Mar 7, 2015
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
//Here's a c++ solution
#include<iostream>
using namespace std;
int main()
{
    int num,a1,b1,c1,a,b,c;
    for(a=1;a<10;++a)
       {
           a1=a*100;
    for(b=0;b<10;++b)
    {
        b1=b*10;
    for(c=0;c<10;c++)
        {c1=c*1;
    num=a1+b1+c1;
    if (num==(a*a*a)+(b*b*b)+(c*c*c))
        cout<<num<<"\n";
       }
       }
       }
return 0;
}

I used C++ too

1
2
3
4
5
6
7
8
9
int main() {
    int count = 0;
    for (int i=100;i<1000;i++) {
        if (i == (i%10)*(i%10)*(i%10) + (i%100/10)*(i%100/10)*(i%100/10) + (i/100)*(i/100)*(i/100)) {
            count++;
        }
    }
    return count;
}

My idea is that the n t h ^{th} digit of a number, i, is given by ( ( i% 1 0 n ) / 1 0 n 1 10^n)/10^{n-1}

Nathanael Case - 5 years, 11 months ago

1
2
3
4
5
6
7
count = 0
for i in range(1,10):
    for j in range(10):
        for k in range(10):
            if i*10**2 + j*10 + k == i**3 + j**3 + k**3:
                count+=1
print(count)

You Kad - 4 years, 10 months ago

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...