login

Year-end appeal: Please make a donation to the OEIS Foundation to support ongoing development and maintenance of the OEIS. We are now in our 61st year, we have over 378,000 sequences, and we’ve reached 11,000 citations (which often say “discovered thanks to the OEIS”).

a(n) is the number of k with 1 < k < sqrt(n) such that n mod k^2 is prime.
3

%I #27 Sep 08 2022 08:46:24

%S 0,0,0,0,0,1,1,0,0,1,2,1,0,2,1,1,0,2,2,1,2,1,3,0,1,1,3,1,2,3,1,2,0,3,

%T 2,1,1,4,4,0,2,2,4,1,1,1,3,2,1,3,3,3,3,2,4,2,2,1,4,1,3,2,2,0,2,5,5,2,

%U 3,2,3,1,1,3,5,0,5,3,3,2,1,3,6,2,2,5,3,3,1,2,3,4,3,3,4,1,1,4,2

%N a(n) is the number of k with 1 < k < sqrt(n) such that n mod k^2 is prime.

%H Robert Israel, <a href="/A329308/b329308.txt">Table of n, a(n) for n = 1..10000</a>

%e a(11) = 2 because 11 == 3 (mod 2^2) and 11 == 2 (mod 3^2), and 2 and 3 are prime.

%p f:= proc(n) local k; nops(select(isprime, [seq(n mod k^2, k=2..floor(sqrt(n)))])) end proc:

%p map(f, [$1..100]);

%t a[n_] := Select[Range[2, Sqrt[n] // Floor], PrimeQ[Mod[n, #^2]]&] // Length;

%t Array[a, 100] (* _Jean-François Alcover_, Jul 17 2020 *)

%o (Magma) a:=[]; for n in [1..100] do Append(~a,#[k:k in [2..Floor(Sqrt(n))]| IsPrime(n mod k^2) ]); end for; a; // _Marius A. Burtea_, Nov 11 2019

%o (PARI) a(n) = sum(j=2, sqrtint(n), isprime(n % j^2)); \\ _Michel Marcus_, Nov 11 2019

%Y Cf. A329203, A329309.

%K nonn

%O 1,11

%A _J. M. Bergot_ and _Robert Israel_, Nov 09 2019