login
a(n) = (prime(n) - a(n-1)) mod 4; a(0)=0.
1

%I #8 Mar 18 2021 08:23:18

%S 0,2,1,0,3,0,1,0,3,0,1,2,3,2,1,2,3,0,1,2,1,0,3,0,1,0,1,2,1,0,1,2,1,0,

%T 3,2,1,0,3,0,1,2,3,0,1,0,3,0,3,0,1,0,3,2,1,0,3,2,1,0,1,2,3,0,3,2,3,0,

%U 1,2,3,2,1,2,3,0,3,2,3,2,3,0,1,2,3,0

%N a(n) = (prime(n) - a(n-1)) mod 4; a(0)=0.

%H Simon Strandgaard, <a href="/A340867/a340867.png">Visualization</a>

%F a(n) = A008347(n) mod 4.

%e a(1) = ( 2 - 0) mod 4 = 2,

%e a(2) = ( 3 - 2) mod 4 = 1,

%e a(3) = ( 5 - 1) mod 4 = 0,

%e a(4) = ( 7 - 0) mod 4 = 3,

%e a(5) = (11 - 3) mod 4 = 0.

%t a[0] = 0; a[n_] := a[n] = Mod[Prime[n] - a[n - 1], 4]; Array[a, 100, 0] (* _Amiram Eldar_, Jan 30 2021 *)

%o (Ruby) require 'prime'

%o values = [0]

%o Prime.first(50).each do |prime|

%o values << (prime-values[-1]) % 4

%o end

%o p values

%Y Cf. A008347, A339448.

%K nonn

%O 0,2

%A _Simon Strandgaard_, Jan 24 2021