login
Let R(i,j) be the infinite square array with antidiagonals 1; 2,3; 4,5,6; ...; the n-th prime is in antidiagonal a(n).
6

%I #41 Jun 19 2024 15:40:59

%S 2,2,3,4,5,5,6,6,7,8,8,9,9,9,10,10,11,11,12,12,12,13,13,13,14,14,14,

%T 15,15,15,16,16,17,17,17,17,18,18,18,19,19,19,20,20,20,20,21,21,21,21,

%U 22,22,22,22,23,23,23,23,24,24,24,24,25,25

%N Let R(i,j) be the infinite square array with antidiagonals 1; 2,3; 4,5,6; ...; the n-th prime is in antidiagonal a(n).

%C The smallest integer in the j-th antidiagonal is A000124(j-1). So a(n) is the index j such that A000124(j-1) <= prime(n) < A000124(j). - _R. J. Mathar_, Dec 02 2011

%H T. D. Noe, <a href="/A057062/b057062.txt">Table of n, a(n) for n = 1..1000</a>

%F a(n) = round(sqrt(2*prime(n))). - _Vladeta Jovovic_, Jun 14 2003

%e The array begins

%e 1 3 6 10 15 ...

%e 2 5 9 14 ...

%e 4 8 13 ...

%e 7 12 ...

%e 11 ...

%e ...

%e The third prime, 5, is in the 3rd antidiagonal, so a(3) = 3.

%t Table[Round[Sqrt[2*Prime[n]]], {n, 100}] (* _T. D. Noe_, Dec 03 2011 *)

%o (PARI) a(n)=(sqrtint(8*prime(n))+1)\2 \\ _Charles R Greathouse IV_, Jul 26 2012

%o (Haskell)

%o a057062 n = a057062_list !! (n-1)

%o a057062_list = f 1 [1..] where

%o f j xs = (replicate (sum $ map a010051 dia) j) ++ f (j + 1) xs'

%o where (dia, xs') = splitAt j xs

%o -- _Reinhard Zumkeller_, Jul 26 2012

%o (Python)

%o from math import isqrt

%o from sympy import prime

%o def A057062(n): return isqrt(prime(n)<<3)+1>>1 # _Chai Wah Wu_, Jun 19 2024

%Y Cf. A057045, A057048, A022846, A057057, A057054. A066888 counts how many times each positive integer appears in this sequence.

%Y Cf. A010051.

%K nonn

%O 1,1

%A _Clark Kimberling_, Jul 30 2000