1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

153 rule

Discussion in 'C++' started by armandodorti, Mar 12, 2011.

  1. armandodorti

    armandodorti New Member

    Joined:
    Mar 12, 2011
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Number 153 has 3 digits and if you take the 3rd power of every digit and calculate the sum of them, you will have the same number again.
    153 = 13 + 53 + 33
    = 1 + 125 + 27 = 153
    Thus for 1634 you should take the fourth powers of every digit (because the number has 4 digits) and calculate the sum.

    How can I express this??
    Please may you help me??
    when i will insert INPUT 100-200 it should show 153.
    INPUT 1000-2000 >>>>show 1634
     
  2. jsh

    jsh New Member

    Joined:
    Mar 18, 2011
    Messages:
    10
    Likes Received:
    0
    Trophy Points:
    0
    Code:
    .
    .
    .
    
    for(int i=1;i<=9;i++)
    for(int j=1;j<=9;j++)
    for(int k=1;k<=9;k++)
    {
    int sum=(i*i*i) + (j*j*j) + (k*k*k);
    if(sum/100==i && sum/10==j && sum%10==k)
    cout<< (i*i*i) + (j*j*j) + (k*k*k) <<" , ";
    }
    .
    .
    .
    
    
     

Share This Page