Problem: A multiple of 7 (Sample Programs)

by lrcvs, Sunday, May 05, 2013, 18:48 (1603 days ago)

What is the smallest number that divided by 2,3,4,5,6, gives a remainder of 1, and it is exactly divisible by 7.

::::::::::::::::::::::::::::::::::::::::::::::::::::::::::

cls
for j = 1 to 1000
l = 0
for k = 2 to 6
if j % k = 1 then l = l + 1
if l = 5 and j % 7 = 0 then
print "Number = "+j
goto zzz
end if
next k
next j
zzz:
end

:::::::::::::::::::::::::::::::::::::::::::

Number = 301

Problem: A multiple of 7

by Jim ⌂ @, Russell, KY, Sunday, May 05, 2013, 21:23 (1603 days ago) @ lrcvs

A bit easier (and faster way to do this).

==========
t = 1 # start at one so we always have one more than (remainder 1)
do
t = t + 2 * 3 * 2 * 5 # LCM of 2,3,4,5, and 6
until t%7 = 0
print t
==========

Jim.

Problem: A multiple of 7

by lrcvs, Sunday, May 05, 2013, 22:09 (1603 days ago) @ Jim

Hi, Jim:

True, your method is faster.!

(These programs do not get bored)

Regards

RSS Feed of thread
powered by my little forum