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

Home > Just Math
Divisibility and Digit Sum (Posted on 2013-06-07) Difficulty: 3 of 5
Determine the total number of seven-digit base 10 positive integers divisible by 11 and having the sum of their digits equal to 59. (No computer programs)

No Solution Yet Submitted by K Sengupta    
No Rating

Comments: ( Back to comment list | You must be logged in to post comments.)
re: No Subject -- verification (spoiler) | Comment 5 of 8 |
(In reply to No Subject by Ady TZIDON)

Since a verification program is to test assumptions (i.e., well-known facts) made in the solution, it would pay to make the test as assumption-free as possible. Here we start with the lowest 7-digit number whose digits add to 59 and proceed until 9999999 is exceeded.


DECLARE FUNCTION digsum# (x#)
DECLARE FUNCTION digroot# (x#)
DEFDBL A-Z
CLS
n = 5999999
mod11 = n MOD 11
n = n + 11 - mod11
dr = digroot(n)
DO
  IF dr = 5 THEN
    IF digsum(n) = 59 THEN
      PRINT n: ct = ct + 1
    END IF
  END IF
  n = n + 11
  dr = dr + 2: IF dr > 9 THEN dr = dr - 9
LOOP UNTIL n > 9999999
PRINT ct

FUNCTION digroot (x)
  s = x
  DO
    s = digsum(s)
  LOOP UNTIL s < 10
  digroot = s
END FUNCTION

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

resulting in:

8699999
8798999
8799989
8897999
8898989
8899979
8996999
8997989
8998979
8999969
9689999
9699899
9699998
9788999
9789989
9798899
9798998
9799889
9799988
9887999
9888989
9889979
9897899
9897998
9898889
9898988
9899879
9899978
9986999
9987989
9988979
9989969
9996899
9996998
9997889
9997988
9998879
9998978
9999869
9999968
40

showing the count is indeed 40.


  Posted by Charlie on 2013-06-07 13:38:53
Please log in:
Login:
Password:
Remember me:
Sign up! | Forgot password


Search:
Search body:
Forums (0)
Newest Problems
Random Problem
FAQ | About This Site
Site Statistics
New Comments (6)
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