A350037 a(n) = n^2 mod round(sqrt(n)).
0, 0, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 4, 4, 1, 0, 1, 4, 4, 1, 0, 1, 4, 3, 4, 1, 0, 1, 4, 3, 4, 1, 0, 1, 4, 2, 2, 4, 1, 0, 1, 4, 2, 2, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 1, 0, 1, 4, 0, 7, 7, 0, 4, 1, 0, 1, 4, 0, 7, 7, 0, 4
Offset: 1
Examples
a(5) = 5^2 mod round(sqrt(5)) = 25 mod 2 = 1.
Links
- Winston de Greef, Table of n, a(n) for n = 1..10000
Crossrefs
Cf. A336302 (with ceiling instead of round).
Programs
-
Java
import java.util.Arrays; public class modulus_sequence { static int[] solutions = new int[480]; static int a_of_n (double n) { int z = (int)Math.round(Math.sqrt(n)); int w = (int)(Math.pow(n, 2)); int k = w%z; return k; } public static void main(String[] args) { for (double j = 2; j < 482; j++) { int h = a_of_n(j); solutions[(int) (j-2)]=h; } System.out.println(Arrays.toString(solutions)); } }
-
Mathematica
a[n_] := Mod[n^2, Round @ Sqrt[n]]; Array[a, 100, 2] (* Amiram Eldar, Dec 10 2021 *) Table[PowerMod[n,2,Round[Sqrt[n]]],{n,2,101}] (* Stefano Spezia, Dec 15 2021 *)
-
PARI
a(n) = n^2 % round(sqrt(n)); \\ Michel Marcus, Dec 14 2021
-
PARI
a(n) = lift(Mod(n, ((sqrtint(4*n) + 1)\2))^2); \\ Michel Marcus, Dec 14 2021
-
Python
from math import isqrt def A350037(n): return pow(n,2,(m:=isqrt(n))+int(4*n>=(2*m+1)**2)) # Chai Wah Wu, Jan 10 2022