All about flooble | fun stuff | Get a free chatterbox | Free JavaScript | Avatars    
perplexus dot info

Home > Just Math
Squaring Up The Digits II (Posted on 2011-09-03) Difficulty: 3 of 5
Determine all possible values of a base ten positive integer N such that N is precisely one more than the sum of the squares of its digits.

No Solution Yet Submitted by K Sengupta    
Rating: 4.3333 (3 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
Solution computer solution | Comment 2 of 7 |

We need not check farther than 3-digit numbers, as 4 * 9^2 = 324 -- only a 3-digit number; and in fact, 3 * 9^2 = 243, so even that number need not be exceeded.

DECLARE FUNCTION sumsq# (x#)
DEFDBL A-Z
FOR n = 1 TO 243
 IF n = sumsq(n) + 1 THEN PRINT n
NEXT n

FUNCTION sumsq (x)
  s$ = LTRIM$(STR$(x))
  t = 0
  FOR i = 1 TO LEN(s$)
   t = t + VAL(MID$(s$, i, 1)) * VAL(MID$(s$, i, 1))
  NEXT
  sumsq = t
END FUNCTION

the results being only 35 and 75.


  Posted by Charlie on 2011-09-03 14:56:00
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (1)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (14)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

Chatterbox:
Copyright © 2002 - 2024 by Animus Pactum Consulting. All rights reserved. Privacy Information