OFFSET
1,22
LINKS
Winston de Greef, Table of n, a(n) for n = 1..10000
FORMULA
EXAMPLE
a(5) = 5^2 mod round(sqrt(5)) = 25 mod 2 = 1.
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 *)
PROG
(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));
}
}
(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
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
Sebastian F. Orellana, Dec 09 2021
STATUS
approved