HP Forums
HP 40gs Programming: Bug or Blindness? - Printable Version

+- HP Forums (https://www.hpmuseum.org/forum)
+-- Forum: HP Calculators (and very old HP Computers) (/forum-3.html)
+--- Forum: General Forum (/forum-4.html)
+--- Thread: HP 40gs Programming: Bug or Blindness? (/thread-9216.html)



HP 40gs Programming: Bug or Blindness? - Gerald H - 10-03-2017 12:30 PM

For natural number input I claim the programme below should produce the sequence

https://oeis.org/A018800

However the calculator resolutely refuses to deliver the members of the sequence.

Is this a defect of the calculator or have I repeatedly missed an error in the programme?

Any suggestions how to get it to work?

Code:
Ans►N:
IF NOT ISPRIME?(Ans)
THEN
0►E:
FOR D=1 TO 6;
N*10►N:
FOR R=1 TO 10^D-1 STEP 2; 
N+R►S:
ISPRIME?(Ans)►E:
IF Ans
THEN
BREAK:
END:
NEXT:
IF E
THEN
BREAK:
END:
NEXT:
S:
END:



RE: HP 40gs Programming: Bug or Blindness? - rpeg1971 - 10-08-2017 05:36 AM

Hi again. Please forget my previous message. Tested your program on the HP40GS emulator and found the error. You only have to replace NEXT: clauses by END: clauses. The program runs fine after these changes. FOR syntax is:

FOR <variable> = <start value> TO <end value> [STEP <increment>] <statements> END