OFFSET
1,3
EXAMPLE
a(2) = (prime(2) + a(1)) mod prime(1) = ( 3 + 1) mod 2 = 0,
a(3) = (prime(3) + a(2)) mod prime(2) = ( 5 + 0) mod 3 = 2,
a(4) = (prime(4) + a(3)) mod prime(3) = ( 7 + 2) mod 5 = 4,
a(5) = (prime(5) + a(4)) mod prime(4) = (11 + 4) mod 7 = 1,
a(6) = (prime(6) + a(5)) mod prime(5) = (13 + 1) mod 11 = 3.
MATHEMATICA
Nest[Append[#1, Mod[(Prime@ #2 + #1[[-1]]), Prime[#2 - 1]]] & @@ {#, Length[#] + 1} &, {1}, 62] (* Michael De Vlieger, Nov 05 2020 *)
PROG
(Ruby) require 'prime'
count = 50
primes = Prime.first(count+1)
values = [1]
count.times { |n| values << (primes[n+1] + values[-1]) % primes[n] }
p values
(PARI) lista(nn) = {my(va = vector(nn)); va[1] = 1; for (n=2, nn, va[n] = (prime(n) + va[n-1]) % prime(n-1); ); va; } \\ Michel Marcus, Nov 05 2020
CROSSREFS
KEYWORD
nonn
AUTHOR
Simon Strandgaard, Nov 01 2020
STATUS
approved