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

Home > Just Math
Respectively Divisible (Posted on 2013-02-04) Difficulty: 3 of 5
The numbers 160, 161 and 162 form a set of three consecutive integers (in order) that are divisible respectively by 5, 7 and 9.

Find the first set of four consecutive integers (in order) that are respectively divisible by 5, 7, 9, and 11.

How about first set of five consecutive integers (in order) that are respectively divisible by 5, 7, 9, 11 and 13.

No Solution Yet Submitted by K Sengupta    
Rating: 4.0000 (1 votes)

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

CLS
FOR n = 5 TO 999999
  m11 = n MOD 11
  IF m11 = 0 THEN
    m9 = n MOD 9
    IF m9 = 1 THEN
      m7 = n MOD 7
      IF m7 = 2 THEN
        m5 = n MOD 5
        IF m5 = 3 THEN PRINT "Part a:"; n - 3; "thru"; n: GOTO p2
      END IF
    END IF
  END IF
NEXT

p2:
FOR n = 5 TO 999999
 m13 = n MOD 13
 IF m13 = 0 THEN
  m11 = n MOD 11
  IF m11 = 1 THEN
    m9 = n MOD 9
    IF m9 = 2 THEN
      m7 = n MOD 7
      IF m7 = 3 THEN
        m5 = n MOD 5
        IF m5 = 4 THEN PRINT "Part b:"; n - 4; "thru"; n: END
      END IF
    END IF
  END IF
 END IF
NEXT

finds

Part a: 1735 thru 1738
Part b: 22525 thru 22529

Of course the above has somewhat silly programming (though speed wasn't a factor here, it is still sloppy coding). The outer loop for part a should have started

FOR n = 11 to 999999 STEP 11

so that the test for divisibility by 11 could have been eliminated.

A similar consideration would be for part b:

FOR n = 13 to 999999 STEP 13

and the test for divisibilty by 13 eliminated.

But the way it was done made copying one set of code to the other easier.


  Posted by Charlie on 2013-02-04 16:34:33
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 (5)
Unsolved Problems
Top Rated Problems
This month's top
Most Commented On

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