So first attempt for challenge 1.
126 seconds to get the first 60 numbers on the stack (then I collected them in a list manually). Hp 50g.
Code:
DIR
@ Problem: www.hpmuseum.org/forum/thread-8178.html
@Description: A regular number is a number that divides evenly a power of
@60 (so at least one of the following numbers 60, 3600, 216000, 604 , 605
@and so on)
@
@Challenge #1: Print on the screen all the regular numbers found in 120
@seconds without gaps (so, without focusing on a subset of the regular
@numbers. One has to return consecutive regular numbers). If the program
@fails to produce any regular number after 120 seconds (unlikely, since
@the first is 2), one can just report the first regular number found and
@how much time was needed. Note: No quick start allowed. One has to start
@from 2.
@
@For example by hand using my el506w as support (or using the properties
@of regular numbers, those are faster to apply mentally) I can do this in
@120 seconds:
@
@2,3,4,5,6,8,9,10,12,15,16,18,20
@
@Challenge #2 (longer): Find the 1429th regular number, return the time
@needed for the computation (I'm not sure if this would stretch thin some
@old calculators). Note: No quick start allowed. One has to start finding
@numbers from 2.
@
@Challenge #2a (for very fast hw/solutions): Like #2, but one has to find
@the 9733rd regular number. (for computers, one has the original
@challenge that raises the bar a bit)
@in short: smart ways to compute regular numbers, that divides evenly at least
@ one power of 60.
mainTimed
\<<
@assuming the input on the stack
'regNumC1v1' TEVAL
\>>
regNumC1v1
@basic approach, dividing power of 60.
@idea is to create the sequence without gaps of the regular numbers
@ so far 21 50 16.04.2017 it works, pretty slow though. 126 seconds to get
@ the list up to 400. 60 regular numbers
\<<
@the idea using factors seems smarter than basic division, but it is not easy
@to formalize, so for the moment, basic divisions or checking factors every time.
2 @counterV
0 @numElV
0 @factorV
10 @uFbreak
\->
@input
upperLimit
@local var
counterV
numElV
factorV
uFbreak
\<<
-3 CF
@this for FACTORS
2 upperLimit
FOR counter
counter FACTORS
@as result list of factors on the stack
OBJ\->
@exploded list, number of elements on the stack L1
'numElV' STO
@we check the factors (in even positions)
@preparation and then loop
2 'counterV' STO
uFbreak CF
WHILE
uFbreak FC?
counterV numElV \<=
AND @ we don't quit the while and we did not finish going through the list.
REPEAT
counterV PICK 'factorV' STO
IF
factorV 2 \=/
factorV 3 \=/
AND
factorV 5 \=/
AND
THEN
@not a regular number
uFbreak SF
END
2 'counterV' STO+
END
numElV DROPN
@clear stack
uFbreak FC? counter IFT
@if there was no break in the factor check loop
@leave the number on the stack
NEXT
\>>
\>>
END
the second challenge fails to produce the 1429th number. I'm waiting since 8h at least, so the code is obviously slow. I do suppose it is the exact mode with FACTORS. Let's try to take it away.