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

Home > Just Math
Another Divisibility Puzzle (Posted on 2006-09-25) Difficulty: 4 of 5
Determine the four smallest but different three digit positive decimal integers commencing with the same digit, such that their sum is divisible by precisely three of the said numbers.

What are the five smallest but different four digit positive decimal integers commencing with the same digit, such that their sum is divisible by precisely four of the said numbers?

See The Solution Submitted by K Sengupta    
Rating: 4.0000 (1 votes)

Comments: ( Back to comment list | You must be logged in to post comments.)
re: General Observation -- program bug Comment 6 of 6 |
(In reply to General Observation by K Sengupta)

Indeed 3 solutions to part 2 once the "smallest" restriction is removed:

 1020  1428  1190  1785  1717              7140
 1080  1512  1260  1890  1818              7560
 1140  1596  1330  1995  1919              7980
 

The bug is the failure to reinitialize tot.  The following segment of the program shows the correction in bold:

FOR d = 1 TO 9
  IF digCt(d) >= 4 THEN
   FOR n1 = 1 TO digCt(d) - 3
   FOR n2 = n1 + 1 TO digCt(d) - 2
   FOR n3 = n2 + 1 TO digCt(d) - 1
   FOR n4 = n3 + 1 TO digCt(d)
    upto = 0
    tot = 0
    FOR i = 1 TO npFct
      IF fact(i) \ 1000 = d THEN
       upto = upto + 1
       IF upto = n1 OR upto = n2 OR upto = n3 OR upto = n4 THEN
         tot = tot + fact(i)
         n(upto) = fact(i)
         IF upto = n4 OR tot > nbr - 999 THEN EXIT FOR
       END IF
      END IF
    NEXT
    diff = nbr - tot
    IF diff \ 1000 = d THEN
      IF nbr MOD diff > 0 THEN
        FOR i = 1 TO 4
         PRINT n(i);
        NEXT
        PRINT diff, nbr
      END IF
    END IF
   NEXT
   NEXT
   NEXT
   NEXT
  END IF
 NEXT

The same correction to the version of the program for part 1 fails to find additional sets of numbers satisfying the conditions.


  Posted by Charlie on 2006-09-26 23:05:17
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 (21)
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