cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A376646 Number of solutions to x + y == x^2 + y^2 (mod n) with x <= y.

This page as a plain text file.
%I A376646 #22 Oct 02 2024 16:08:56
%S A376646 1,3,3,6,3,10,5,10,7,10,7,20,7,18,10,18,9,26,11,20,18,26,13,36,11,26,
%T A376646 19,36,15,36,17,34,26,34,18,52,19,42,26,36,21,68,23,52,26,50,25,68,29,
%U A376646 42,34,52,27,74,26,68,42,58,31,72,31,66,50,66,26,100,35,68,50,68
%N A376646 Number of solutions to x + y == x^2 + y^2 (mod n) with x <= y.
%H A376646 Alois P. Heinz, <a href="/A376646/b376646.txt">Table of n, a(n) for n = 1..4000</a>
%p A376646 a:=proc(n)
%p A376646  local x,y,count;
%p A376646   count:=0:
%p A376646   for x from 0 to n-1 do
%p A376646    for y from x to n-1 do
%p A376646      if (x+y) mod n =(x^2+y^2) mod n  then count:=count+1; fi;
%p A376646    od:
%p A376646   od:
%p A376646   count;
%p A376646 end:
%p A376646 # second Maple program:
%p A376646 a:= n-> add(add(`if`(x^2-x+y^2-y mod n=0, 1, 0), x=0..y), y=0..n-1):
%p A376646 seq(a(n), n=1..70);  # _Alois P. Heinz_, Oct 01 2024
%o A376646 (PARI) a(n) = sum(y=0, n-1, sum(x=0, y, (x+y) % n == (x^2+y^2) % n)); \\ _Michel Marcus_, Oct 01 2024
%o A376646 (Python)
%o A376646 def A376646(n):
%o A376646     c = 0
%o A376646     for x in range(n):
%o A376646         m = x*(1-x)%n
%o A376646         c += sum(1 for y in range(x,n) if y*(y-1)%n==m)
%o A376646     return c # _Chai Wah Wu_, Oct 02 2024
%K A376646 nonn,look
%O A376646 1,2
%A A376646 _W. Edwin Clark_, Sep 30 2024