northwolves 发表于 7 天前

northwolves 发表于 2025-1-12 17:10
(PARI) a(n)=t=sqrtint(n); if((n-t*t)%2==0, (n-t*t)/2, ((t+1)^2-n)/2) \\ Ralf Stephan, Sep 23 2013


a :=Block[{t = Floor@Sqrt@n, s = n - t^2},If, s/2, t + (1 - s)/2]];
Table, {n, 0, 100}]

{0,0,1,1,0,2,1,1,2,0,3,1,2,2,1,3,0,4,1,3,2,2,3,1,4,0,5,1,4,2,3,3,2,4,1,5,0,6,1,5,2,4,3,3,4,2,5,1,6,0,7,1,6,2,5,3,4,4,3,5,2,6,1,7,0,8,1,7,2,6,3,5,4,4,5,3,6,2,7,1,8,0,9,1,8,2,7,3,6,4,5,5,4,6,3,7,2,8,1,9,0}
页: 1 [2]
查看完整版本: 会出现规律吗?