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 
Complex Prime Number Test
11-11-2014, 06:09 PM (This post was last modified: 11-13-2014 01:21 PM by Eddie W. Shore.)
Post: #1
Complex Prime Number Test
Program:
Code:
EXPORT cisprime(z)
BEGIN
// 2014-11-09 EWS
LOCAL a,b,r,t;
a:=RE(z);
b:=IM(z);
r:=a^2+b^2;
IF CAS.isPrime(r)==1 THEN
t:=1; END;
IF a==0 AND ABS(b) MOD 4==3 AND CAS.isprime(ABS(b))==1 THEN
t:=1; END;
IF b==0 AND ABS(a) MOD 4==3 AND CAS.isprime(ABS(a))==1 THEN
t:=1; END;
RETURN t;
END;
(Edited 2014-11-13, see the thread - thanks Joe and Thomas!)


Examples:
cisprime(2-4*i) returns 0
cisprime(-2+5*i) returns 1

Source: http://mathworld.wolfram.com/GaussianPrime.html
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Complex Prime Number Test - Eddie W. Shore - 11-11-2014 06:09 PM
RE: Complex Prime Number Test - Jim Horn - 11-12-2014, 04:41 PM



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