%I #21 Oct 23 2015 11:28:50
%S 3,11,13,21,31,101,111,113,123,133,201,211,213,223,233,301,321,323,
%T 331,1003,1011,1021,1031,1033,1101,1113,1123,1131,1133,1201,1203,1213,
%U 1223,1231,1233,1311,1321,1323,2001,2011,2031,2033,2103,2113,2131,2133,2203
%N Quater-imaginary representation of the Gaussian primes with an even imaginary part.
%C Not all Gaussian primes will be in this list as complex numbers with an odd imaginary part require a value after the radix point (".") in the quater-imaginary number system.
%H Donald Knuth, <a href="http://dl.acm.org/citation.cfm?id=367233">An imaginary number system</a>, Communications of the ACM 3 (4), April 1960, pp. 245-247.
%H OEIS Wiki, <a href="/wiki/Quater-imaginary_base">Quater-imaginary base</a>
%H OEIS Wiki, <a href="https://oeis.org/wiki/Gaussian_primes">Gaussian primes</a>
%H Wikipedia, <a href="http://en.wikipedia.org/wiki/Quater-imaginary_base">Quater-imaginary base</a>
%e 1231_(2i) = 1(2i)^3 + 2(2i)^2 + 3(2i)^1 + 1(2i)^0 = -7-2i which is a Gaussian prime.
%o (C++)
%o #include <stdlib.h>
%o #include <math.h>
%o #include <iostream>
%o #include <fstream>
%o using namespace std;
%o bool isPrime(int n)
%o {
%o if (n <= 1)
%o return false;
%o if (n == 2)
%o return true;
%o if (n % 2 == 0)
%o return false;
%o int rootNCeil = (int)sqrt(n) + 1;
%o for (int div = 3; div <= rootNCeil;div+=2)
%o {
%o if (n % div == 0)
%o return false;
%o }
%o return true;
%o }
%o int main()
%o {
%o const int maxDigits = 8;
%o unsigned int maxVal = 2 << ((maxDigits * 2) - 1);
%o for (unsigned int n = 0; n < maxVal; n++)
%o {
%o // Split binary representation of n into real part and imaginary part
%o int rp = (n & 0x00000003) - ((n & 0x00000030) >> 2) +
%o ((n & 0x00000300) >> 4) - ((n & 0x00003000) >> 6) +
%o ((n & 0x00030000) >> 8) - ((n & 0x00300000) >> 10) +
%o ((n & 0x03000000) >> 12) - ((n & 0x30000000) >> 14);
%o int ip = ((n & 0x0000000c) >> 1) - ((n & 0x000000c0) >> 3) +
%o ((n & 0x00000c00) >> 5) - ((n & 0x0000c000) >> 7) +
%o ((n & 0x000c0000) >> 9) - ((n & 0x00c00000) >> 11) +
%o ((n & 0x0c000000) >> 13) - ((n & 0xc0000000) >> 15);
%o if ((ip == 0 && (abs(rp) % 4 == 3) && isPrime(abs(rp))) ||
%o (rp == 0 && (abs(ip) % 4 == 3) && isPrime(abs(ip))) ||
%o (rp != 0 && ip != 0 && isPrime(rp*rp + ip*ip)) )
%o {
%o char digits[maxDigits + 1];
%o _itoa(n, digits, 4);
%o cout<<digits << "," << rp << (ip >= 0 ? "+" : "") << ip << "i\n";
%o }
%o }
%o }
%Y A002145 when translated using A212494 is a subsequence.
%Y Real and imaginary parts of the Gaussian primes A103431, A103432.
%K nonn,base
%O 1,1
%A _Adam J.T. Partridge_, Sep 22 2015
|