login
a(n) = n^2 mod round(sqrt(n)).
1

%I #43 Oct 03 2023 10:55:58

%S 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,

%T 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,

%U 1,4,1,0,1,4,0,7,7,0,4,1,0,1,4,0,7,7,0,4

%N a(n) = n^2 mod round(sqrt(n)).

%H Winston de Greef, <a href="/A350037/b350037.txt">Table of n, a(n) for n = 1..10000</a>

%F a(n) = A000290(n) mod A000194(n). - _Michel Marcus_, Dec 14 2021

%e a(5) = 5^2 mod round(sqrt(5)) = 25 mod 2 = 1.

%t a[n_] := Mod[n^2, Round @ Sqrt[n]]; Array[a, 100, 2] (* _Amiram Eldar_, Dec 10 2021 *)

%t Table[PowerMod[n,2,Round[Sqrt[n]]],{n,2,101}] (* _Stefano Spezia_, Dec 15 2021 *)

%o (Java)

%o import java.util.Arrays;

%o public class modulus_sequence {

%o static int[] solutions = new int[480];

%o static int a_of_n (double n) {

%o int z = (int)Math.round(Math.sqrt(n));

%o int w = (int)(Math.pow(n, 2));

%o int k = w%z;

%o return k;

%o }

%o public static void main(String[] args) {

%o for (double j = 2; j < 482; j++) {

%o int h = a_of_n(j);

%o solutions[(int) (j-2)]=h;

%o }

%o System.out.println(Arrays.toString(solutions));

%o }

%o }

%o (PARI) a(n) = n^2 % round(sqrt(n)); \\ _Michel Marcus_, Dec 14 2021

%o (PARI) a(n) = lift(Mod(n, ((sqrtint(4*n) + 1)\2))^2); \\ _Michel Marcus_, Dec 14 2021

%o (Python)

%o from math import isqrt

%o def A350037(n): return pow(n,2,(m:=isqrt(n))+int(4*n>=(2*m+1)**2)) # _Chai Wah Wu_, Jan 10 2022

%Y Cf. A336302 (with ceiling instead of round).

%K nonn,easy

%O 1,22

%A _Sebastian F. Orellana_, Dec 09 2021