(12C) Check if given number is Prime Number or not
09-10-2018, 08:49 AM (This post was last modified: 09-10-2018 09:02 AM by Gamo.)
Post: #1
 Gamo Senior Member Posts: 518 Joined: Dec 2016
(12C) Check if given number is Prime Number or not
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:
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
 « Next Oldest | Next Newest »

 Messages In This Thread (12C) Check if given number is Prime Number or not - Gamo - 09-10-2018 08:49 AM RE: (12C) Check if given number is Prime Number or not - Joe Horn - 09-10-2018, 04:16 PM RE: (12C) Check if given number is Prime Number or not - Dieter - 09-10-2018, 06:48 PM RE: (12C) Check if given number is Prime Number or not - Albert Chan - 09-10-2018, 10:18 PM RE: (12C) Check if given number is Prime Number or not - Thomas Klemm - 09-11-2018, 03:12 AM RE: (12C) Check if given number is Prime Number or not - Gamo - 09-11-2018, 05:42 AM RE: (12C) Check if given number is Prime Number or not - Dieter - 09-11-2018, 07:18 AM RE: (12C) Check if given number is Prime Number or not - Thomas Klemm - 09-11-2018, 06:45 AM RE: (12C) Check if given number is Prime Number or not - Gamo - 09-11-2018, 08:03 AM RE: (12C) Check if given number is Prime Number or not - Dieter - 09-13-2018, 06:35 PM RE: (12C) Check if given number is Prime Number or not - rprosperi - 09-13-2018, 08:52 PM RE: (12C) Check if given number is Prime Number or not - Albert Chan - 09-13-2018, 09:35 PM RE: (12C) Check if given number is Prime Number or not - rprosperi - 09-13-2018, 11:21 PM RE: (12C) Check if given number is Prime Number or not - Dieter - 09-14-2018, 12:18 PM RE: (12C) Check if given number is Prime Number or not - rprosperi - 09-14-2018, 04:19 PM RE: (12C) Check if given number is Prime Number or not - Dieter - 09-14-2018, 06:33 PM RE: (12C) Check if given number is Prime Number or not - rprosperi - 09-14-2018, 08:15 PM

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