cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A219219 Numbers k such that 2^k (mod k^2) is prime.

This page as a plain text file.
%I A219219 #17 May 21 2021 11:28:48
%S A219219 5,21,53,55,61,95,111,155,165,189,193,213,221,227,245,249,257,289,291,
%T A219219 303,305,307,317,339,345,355,363,383,385,423,429,437,457,465,477,505,
%U A219219 577,597,601,607,621,653,655,679,705,715,727,749,751,765,781,849,889,939
%N A219219 Numbers k such that 2^k (mod k^2) is prime.
%C A219219 Indices of primes in A066606.
%H A219219 Michael S. Branicky, <a href="/A219219/b219219.txt">Table of n, a(n) for n = 1..10000</a> (terms 1..1000 from Alois P. Heinz)
%p A219219 a:= proc(n) option remember; local k;
%p A219219       for k from 1+ `if`(n=1, 0, a(n-1))
%p A219219       while not isprime(2 &^k mod k^2) do od; k
%p A219219     end:
%p A219219 seq (a(n), n=1..100);  # _Alois P. Heinz_, Nov 17 2012
%t A219219 Flatten[Position[Table[PowerMod[2, k, k^2], {k, 1000}], _?(PrimeQ[#] &)]] (* _T. D. Noe_, Nov 15 2012 *)
%t A219219 Select[Range[1000],PrimeQ[PowerMod[2,#,#^2]]&] (* _Harvey P. Dale_, Mar 29 2020 *)
%o A219219 (Java)
%o A219219 import java.math.BigInteger;
%o A219219 public class A219219 {
%o A219219   public static void main (String[] args) {
%o A219219     BigInteger b2 = BigInteger.valueOf(2);
%o A219219     for (int n=1; ; n++) {
%o A219219       BigInteger bn = BigInteger.valueOf(n);
%o A219219       BigInteger pp  = b2.modPow(bn, bn.multiply(bn));
%o A219219       if (pp.isProbablePrime(2)) {
%o A219219           if (pp.isProbablePrime(80))
%o A219219               System.out.printf("%d, ",n);
%o A219219       }
%o A219219     }
%o A219219   }
%o A219219 }
%o A219219 (Python)
%o A219219 from sympy import isprime
%o A219219 def aupto(limit):
%o A219219   alst = []
%o A219219   for k in range(1, limit+1):
%o A219219     if isprime(pow(2, k, k*k)): alst.append(k)
%o A219219   return alst
%o A219219 print(aupto(939)) # _Michael S. Branicky_, May 21 2021
%Y A219219 Cf. A066606.
%K A219219 nonn
%O A219219 1,1
%A A219219 _Alex Ratushnyak_, Nov 15 2012