login
a(n) is the smallest k such that the square root of k*n rounds to a prime.
4

%I #34 Oct 19 2022 13:40:21

%S 3,2,1,1,1,1,1,1,1,1,1,1,2,2,2,3,3,3,6,6,1,1,1,1,1,1,1,1,1,1,4,4,4,5,

%T 5,5,3,3,3,3,3,3,1,1,1,1,1,1,1,1,1,1,1,1,1,1,2,2,2,2,2,2,2,2,2,2,8,8,

%U 4,4,4,4,4,4,4,4,7,7,2,2,2,2,2,2,2,2,2,2,2,2,2,3,3,3,3

%N a(n) is the smallest k such that the square root of k*n rounds to a prime.

%H Michael De Vlieger, <a href="/A357477/b357477.txt">Table of n, a(n) for n = 1..10000</a>

%e a(19) = 6 because sqrt(19*6) rounded to the nearest integer is 11, which is prime. Any multiple smaller than this only rounds to a composite number.

%t Array[(k = 1; While[! PrimeQ[Round@ Sqrt[k #]], k++]; k) &, 105] (* _Michael De Vlieger_, Oct 19 2022 *)

%o (PARI) a(n) = my(k=1); while (!isprime(round(sqrt(k*n))), k++); k; \\ _Michel Marcus_, Oct 18 2022

%o (Python)

%o from math import isqrt

%o from itertools import count

%o from sympy import isprime

%o def A357477(n): return next(filter(lambda k:isprime((m:=isqrt(k*n))+ int((k*n-m*(m+1)<<2)>=1)),count(1))) # _Chai Wah Wu_, Oct 19 2022

%Y Cf. A357675, A357676.

%K nonn,easy

%O 1,1

%A _Jake M. Gotlieb_, Sep 30 2022