Results 1 to 4 of 4
  1. #1
    Sorena is offline Member
    Join Date
    Nov 2010
    Posts
    1
    Rep Power
    0

    Default How can I do this program?

    Write a program that will find all the three digit natural numbers that are equal to the sum of the cubes of their digits. Maximum 3 digit number is 999. What is the first?

  2. #2
    funnyboy's Avatar
    funnyboy is offline Member
    Join Date
    Nov 2010
    Posts
    10
    Rep Power
    0

    Cool

    To multiply all digits divide the number by ten and store the leftover in another variable (by using the % operator). Then divide the left number by ten again and so on.

  3. #3
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    14,422
    Blog Entries
    7
    Rep Power
    28

    Default

    Quote Originally Posted by Sorena View Post
    Write a program that will find all the three digit natural numbers that are equal to the sum of the cubes of their digits. Maximum 3 digit number is 999. What is the first?
    153; do you really lack the imagination to come up with the condition:

    Java Code:
    	if (100*a+10*b+c == a*a*a+b*b*b+c*c*c)
    in a triple nested loop for values of a in [1,9] and values of b and c in [0,9];
    ... if so, programming is not for you.

    kind regards,

    Jos
    Build a wall around Donald Trump; I'll pay for it.

  4. #4
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    10

Similar Threads

  1. changing my program to array working program
    By Chewart in forum New To Java
    Replies: 39
    Last Post: 11-18-2009, 06:53 PM
  2. Execute A program from a Program!
    By Moncleared in forum Advanced Java
    Replies: 2
    Last Post: 02-22-2009, 04:17 PM
  3. Executing a program within a program
    By gibsonrocker800 in forum New To Java
    Replies: 5
    Last Post: 05-12-2008, 08:24 AM
  4. Replies: 0
    Last Post: 04-04-2008, 02:40 PM
  5. Replies: 0
    Last Post: 10-04-2007, 09:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •