|
|
A350037
|
|
a(n) = n^2 mod round(sqrt(n)).
|
|
1
|
|
|
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
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,22
|
|
LINKS
|
|
|
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
|
Cf. A336302 (with ceiling instead of round).
|
|
KEYWORD
|
nonn,easy
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|