A320471 a(n) = floor(sqrt(n)) mod ceiling(sqrt(n)).
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, 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, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 0, 9, 9, 9, 9, 9, 9
Offset: 1
Keywords
Programs
-
Magma
[Binomial(Ceiling(Sqrt(n)), Floor(Sqrt(n))) - 1: n in [1..100]]; // Vincenzo Librandi, Dec 02 2018
-
Maple
a:= proc(n) modp(floor(sqrt(n)),ceil(sqrt(n))) end: seq(a(n),n=1..100); # Muniru A Asiru, Oct 17 2018
-
Mathematica
Array[Mod[Floor@ #, Ceiling@ #] &@ Sqrt@ # &, 99] (* or *) Array[IntegerPart@ # - If[IntegerQ@ #, #, 0] &@ Sqrt@ # &, 99] (* or *) Flatten@ Array[{0}~Join~ConstantArray[#, 2 #] &, 9] (* Michael De Vlieger, Oct 15 2018 *)
-
PARI
a(n) = sqrtint(n) % (1+sqrtint(n-1)); \\ Michel Marcus, Nov 04 2018
-
PARI
a(n) = sqrtint(n-1) * !issquare(n) \\ David A. Corneth, Nov 04 2018
-
Python
from math import isqrt def A320471(n): return 0 if (m:=isqrt(n))**2==n else m # Chai Wah Wu, Jul 29 2022
Formula
Extensions
Corrected by Michel Marcus, Jun 14 2022
Comments