

A236768


A recurrence relation conditioned on the primality of the preceding terms.


1



1, 2, 3, 5, 8, 13, 21, 34, 13, 47, 60, 107, 167, 274, 441, 167, 608, 775, 167, 942, 1109, 2051, 3160, 1109, 4269, 5378, 1109, 6487, 7596, 1109, 8705, 9814, 1109, 10923, 12032, 1109, 13141, 14250, 1109, 15359, 16468, 31827, 15359, 47186, 62545, 15359, 77904, 93263, 171167, 264430
(list;
graph;
refs;
listen;
history;
text;
internal format)



OFFSET

0,2


COMMENTS

This is like the Fibonacci sequence but subtraction replaces addition when neither of the preceding two terms are prime numbers.


LINKS

Paul Tek, Table of n, a(n) for n = 0..1000


FORMULA

a(0) = 1, a(1) = 2, a(n) = a(n1) + a(n2) unless both a(n1) and a(n2) are composite, then a(n) = a(n1)  a(n2).


EXAMPLE

a(6) = 21 because a(5)=13 is prime and 13 + 8 = 21.
a(7) = 34 because a(5) is prime and 21 + 13 = 34.
a(8) = 13 because neither a(6) nor a(7) is prime and 34  21 = 13.


MATHEMATICA

modFibo[0] := 1; modFibo[1] := 2; modFibo[n_] := modFibo[n] = modFibo[n  1] + (1)^(Boole[Not[PrimeQ[modFibo[n  1]]  PrimeQ[modFibo[n  2]]]])modFibo[n  2]; Table[modFibo[n], {n, 0, 49}] (* Alonso del Arte, Jan 31 2014 *)


CROSSREFS

Sequence in context: A013986 A121343 A321021 * A023439 A147660 A013987
Adjacent sequences: A236765 A236766 A236767 * A236769 A236770 A236771


KEYWORD

nonn,easy


AUTHOR

Stephen McDonald, Jan 30 2014


STATUS

approved



