login
a(n) = floor(sqrt(n)) mod ceiling(sqrt(n)).
2

%I #81 Feb 12 2023 14:48:35

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

%T 5,0,6,6,6,6,6,6,6,6,6,6,6,6,0,7,7,7,7,7,7,7,7,7,7,7,7,7,7,0,8,8,8,8,

%U 8,8,8,8,8,8,8,8,8,8,8,8,0,9,9,9,9,9,9

%N a(n) = floor(sqrt(n)) mod ceiling(sqrt(n)).

%C Sequence consists of zeros interleaved with the positive integers, each positive integer k appearing 2k times.

%F a(n) = A000196(n) - A037213(n).

%F a(n) = A000196(n)*A049240(n).

%F a(n) = A000196(n) mod A003059(n).

%F a(n) = (n - A173517(n)) - A037213(n)^2.

%F a(n) = binomial(ceiling(sqrt(n)),floor(sqrt(n))) - 1.

%F From _David A. Corneth_, Nov 04 2018: (Start)

%F a(k^2) = 0.

%F a(m) = floor(sqrt(m)) for nonsquare m. (End)

%p a:= proc(n) modp(floor(sqrt(n)),ceil(sqrt(n))) end: seq(a(n),n=1..100); # _Muniru A Asiru_, Oct 17 2018

%t Array[Mod[Floor@ #, Ceiling@ #] &@ Sqrt@ # &, 99] (* or *)

%t Array[IntegerPart@ # - If[IntegerQ@ #, #, 0] &@ Sqrt@ # &, 99] (* or *)

%t Flatten@ Array[{0}~Join~ConstantArray[#, 2 #] &, 9] (* _Michael De Vlieger_, Oct 15 2018 *)

%o (PARI) a(n) = sqrtint(n) % (1+sqrtint(n-1)); \\ _Michel Marcus_, Nov 04 2018

%o (PARI) a(n) = sqrtint(n-1) * !issquare(n) \\ _David A. Corneth_, Nov 04 2018

%o (Magma)

%o [Binomial(Ceiling(Sqrt(n)), Floor(Sqrt(n))) - 1: n in [1..100]]; // _Vincenzo Librandi_, Dec 02 2018

%o (Python)

%o from math import isqrt

%o def A320471(n): return 0 if (m:=isqrt(n))**2==n else m # _Chai Wah Wu_, Jul 29 2022

%Y Cf. A000196, A003059, A037213, A049240, A173517.

%K nonn

%O 1,5

%A _Kritsada Moomuang_, Oct 13 2018

%E Corrected by _Michel Marcus_, Jun 14 2022