The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
(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
(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
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(12C) Check if given number is Prime Number or not - Gamo - 09-10-2018 08:49 AM



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