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

%I #12 Dec 23 2020 19:52:31

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

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

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

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

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

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

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

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

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

%t a[0]=0; a[n_]:=Mod[Prime[n]-a[n-1],3]; Table[a[n],{n,0,85}] (* _Stefano Spezia_, Dec 05 2020 *)

%o (Ruby) require 'prime'

%o values = [0]

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

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

%o end

%o p values

%Y Cf. A008347.

%K nonn

%O 0,2

%A _Simon Strandgaard_, Dec 05 2020