26 - PS - Prime number calculation (fast)

Post Reply
Peet
Posts: 91
Joined: Tue Sep 29, 2020 12:01 am
Location: Germany

26 - PS - Prime number calculation (fast)

Post by Peet »

Code: Select all

LBL "PS"
6
/
INT
6
*
1
+
STO 01
LBL 00
XEQ 01
4
ST+ 01
XEQ 01
2
ST+ 01
GTO 00
LBL 01
5
STO 02
LBL 02
RCL 01
RCL 02
MOD
X=0?
RTN 
2 	
ST+ 02
RCL 01
RCL 02
MOD
X=0?
RTN 
4
ST+ 02
RCL 01
SQRT
RCL 02
X<=Y?
GTO 02
"P="
ARCL 01
AVIEW
PSE
END


Computes prime numbers starting from x (>= 11) approx. 30% faster than "PZ"

Input: <x> R/S
Output: starts with a prime number next to x
Attachments
26_PS_Primzahlen.raw
(65 Bytes) Downloaded 3 times
My programmable calculators - former: CBM PR100, HP41CV, HP28S, HP11C - current: HP48G(+), HP35S, DM41X, DM42
Post Reply