Post Reply 
RPL second impressions (HP 28)
06-27-2018, 05:11 PM (This post was last modified: 06-27-2018 05:12 PM by mdunn.)
Post: #12
RE: RPL second impressions (HP 28)
Enter an odd number ≥5 and it will return the number if prime, or the next prime if not. CONT will return succeeding primes.

I know…it’s a poor program, and should really be two programs, have local variables, etc. It was just an exercise. What were my syntax errors? Writing STO var instead of ‘var’ STO. And not using the correct WHILE syntax.

Argh…is there no way to stop the 28 from mangling my nice formatting?

Code:
;Prime number checker/generator
;Michael Dunn, 2018/6/27

«
‘Primes’ STO
1 ‘TestDiv’ STO

WHILE 1 REPEAT
  2 ‘TestDiv’ STO+
   IF ‘NOT FP(Primes/TestDiv)’ EVAL
     THEN
       2 ‘Primes’ STO+
       1 ‘TestDiv’ STO
     ELSE
       IF ‘SQ(TestDiv) > Primes’ EVAL
         THEN
           1245 .3 BEEP Primes HALT
           2 ‘Primes’ STO+
           1 ‘TestDiv’ STO
      END
  END
END
»
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RPL second impressions (HP 28) - mdunn - 06-27-2018, 01:19 AM
RE: RPL second impressions (HP 28) - mdunn - 06-27-2018, 01:58 PM
RE: RPL second impressions (HP 28) - mdunn - 06-27-2018, 04:06 PM
RE: RPL second impressions (HP 28) - mdunn - 06-27-2018 05:11 PM
RE: RPL second impressions (HP 28) - mdunn - 06-27-2018, 07:45 PM
RE: RPL second impressions (HP 28) - mdunn - 06-28-2018, 08:48 PM
RE: RPL second impressions (HP 28) - ttw - 07-04-2018, 10:52 PM



User(s) browsing this thread: 1 Guest(s)