Wednesday, November 12, 2014

Casio fx-9750gII, fx-9860gII, Prizm: Prime and Complex Number Prime (Gaussian Prime)

Let /rtri be the right triangle symbol (display symbol)

Real Number Primes

Program ISPRIME:

“REAL PRIME”
“EWS 2014-11-12”
“N”?->N
Int N->N
For 2->K To S
If Frac (N÷K)=0
Then
“NOT PRIME” /rtri
Stop
IfEnd
Next
“PRIME”

 Examples:
19 is PRIME
36 is NOT PRIME

Complex Number Primes
(Gaussian Primes)


Program CISPRIME:

“COMPLEX PRIME”
“EWS 2014-11-12”
a+bi
“Z”?->Z
(Abs Z)^2->T
If ReP Z=0 or ImP Z=0
Then
Goto 1
IfEnd
For 2->K To Abs Z
If Frac(T÷K)=0
Then Goto 2
IfEnd
Next
Goto 3
Lbl 1
If MOD(Abs Z, 4)≠3
Then Goto 2
IfEnd
Next
Goto 3
Lbl 2
“NOT PRIME” /rtri
Stop
Lbl 3
“PRIME”

Examples:
2+2i is not (complex) prime
7 is (complex) prime
-5+4i is (complex) prime
 
 
This blog is property of Edward Shore.  2014
 
Blog Entry #404