login
a(n) = prime(n-2) - a(n-2) for n > 2, starting with a(1)=1, a(2)=1.
0

%I #29 Sep 05 2020 05:45:29

%S 1,1,1,2,4,5,7,8,10,11,13,18,18,19,23,24,24,29,35,32,32,39,41,40,42,

%T 49,55,52,48,55,61,58,66,73,71,66,78,85,79,78,88,95,91,86,100,107,97,

%U 92,114,131,113,98,120,141,121,110,136,153,133,118,144,163,139,130

%N a(n) = prime(n-2) - a(n-2) for n > 2, starting with a(1)=1, a(2)=1.

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

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

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

%e a(6) = prime(4) - a(4) = 7 - 2 = 5,

%e a(7) = prime(5) - a(5) = 11 - 4 = 7,

%e a(8) = prime(6) - a(6) = 13 - 5 = 8,

%e a(9) = prime(7) - a(7) = 17 - 7 = 10.

%t a[1] = a[2] = 1; a[n_] := a[n] = Prime[n - 2] - a[n - 2] ; Array[a, 100] (* _Amiram Eldar_, Jul 16 2020 *)

%o (Ruby) require 'prime'

%o values = [1, 1]

%o Prime.each(500) {|prime| values << prime - values[-2] }

%o p values

%o (PARI) a(n) = if (n<=2, 1, prime(n-2) - a(n-2)); \\ _Michel Marcus_, Jul 16 2020

%Y Cf. A000040, A275017.

%K nonn

%O 1,4

%A _Simon Strandgaard_, Jul 13 2020