login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A142878 a(n) = 1 if a(n-1) is prime, otherwise a(n-1) + a(n-2), with a(0) = 0 and a(1) = 1. 1
0, 1, 1, 2, 1, 3, 1, 4, 5, 1, 6, 7, 1, 8, 9, 17, 1, 18, 19, 1, 20, 21, 41, 1, 42, 43, 1, 44, 45, 89, 1, 90, 91, 181, 1, 182, 183, 365, 548, 913, 1461, 2374, 3835, 6209, 10044, 16253, 1, 16254, 16255, 32509, 48764 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,4
LINKS
FORMULA
a(n) = 1 if a(n-1) is prime, otherwise a(n-1) + a(n-2), with a(0) = 0 and a(1) = 1.
MATHEMATICA
(* First program *)
a[n_]:= a[n]= If[n<2, n, If[PrimeQ[a[n-1]], 1, a[n-1] + a[n-2]]];
Table[a[n], {n, 0, 50}]
(* Second program *)
nxt[{a_, b_}]:={b, If[PrimeQ[b], 1, a+b]}; NestList[nxt, {0, 1}, 50][[All, 1]] (* Harvey P. Dale, Jan 31 2020 *)
PROG
(Sage)
@CachedFunction
def a(n):
if (n<2): return n
elif (is_prime(a(n-1))): return 1
else: return a(n-1) + a(n-2)
[a(n) for n in (0..50)] # G. C. Greubel, Feb 10 2021
CROSSREFS
Sequence in context: A325365 A177687 A219356 * A299774 A362254 A341866
KEYWORD
nonn,easy
AUTHOR
Roger L. Bagula, Sep 28 2008
EXTENSIONS
Edited by G. C. Greubel, Feb 10 2021
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 19 06:16 EDT 2024. Contains 371782 sequences. (Running on oeis4.)