09-10-2018, 08:49 AM
Program to check if the given number is Prime Number or Not.
1 Display is Yes this is a prime number
0 Display is No this is not a prime number
Procedure: n [R/S] display 0 or 1 [X<>Y] your given number
Example:
199 [R/S] display 1 // Yes this is a prime number
[X<>Y] display 199
153 [R/S] display 0 // No this is not a prime number
[X<>Y] display 153
Program:
Remark:
The larger the number the longer time it takes to give result even on HP-12C+
when the display show "running" and keep going that always is a prime number since
the result when it is not a prime number will show 0 instantly.
On the HP-12C emulator this program run extremely fast.
Gamo
1 Display is Yes this is a prime number
0 Display is No this is not a prime number
Procedure: n [R/S] display 0 or 1 [X<>Y] your given number
Example:
199 [R/S] display 1 // Yes this is a prime number
[X<>Y] display 199
153 [R/S] display 0 // No this is not a prime number
[X<>Y] display 153
Program:
Code:
01 STO 1
02 1
03 X<>Y
04 X≤Y
05 GTO 26
06 CLx
07 STO 2
08 2
09 STO 2
10 RCL 2
11 RCL 1
12 X≤Y
13 GTO 23
14 RCL 1
15 RCL 2
16 ÷
17 FRAC
18 X=0
19 GTO 26
20 1
21 STO+2
22 GTO 10
23 RCL 1
24 1
25 GTO 00
26 RCL 1
27 0
28 GTO 00
Remark:
The larger the number the longer time it takes to give result even on HP-12C+
when the display show "running" and keep going that always is a prime number since
the result when it is not a prime number will show 0 instantly.
On the HP-12C emulator this program run extremely fast.
Gamo