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!)
A192439 a(n) = a(n-1) - a(n-2) if n is prime or a(n-1) + a(n-2) otherwise. a(1) = a(2) = 1. 1

%I #25 Apr 21 2024 10:01:43

%S 1,1,0,1,1,2,1,3,4,7,3,10,7,17,24,41,17,58,41,99,140,239,99,338,437,

%T 775,1212,1987,775,2762,1987,4749,6736,11485,18221,29706,11485,41191,

%U 52676,93867,41191,135058,93867,228925,322792,551717,228925,780642,1009567

%N a(n) = a(n-1) - a(n-2) if n is prime or a(n-1) + a(n-2) otherwise. a(1) = a(2) = 1.

%H Reinhard Zumkeller, <a href="/A192439/b192439.txt">Table of n, a(n) for n = 1..1000</a>

%F a(n) = a(n-1) + a(n-2), if n is nonprime.

%F a(n) = a(n-1) - a(n-2), if n is prime.

%F a(1) = a(2) = 1.

%F a(n) >> x^n, with x = 1.28743... the largest real root of x^6 - x^5 + x^4 - x^3 + x^2 - x = 2. - _Charles R Greathouse IV_, Jul 01 2011

%e a(1) = 1, a(2) = 1.

%e a(3) = 1 - 1 = 0, as n=3 is prime.

%e a(4) = 0 + 1 = 1, as n=4 is nonprime.

%e a(5) = 1 - 0 = 1, as n=5 is prime.

%e a(6) = 1 + 1 = 2, as n=6 is nonprime.

%t nxt[{n_,a_,b_}]:={n+1,b,If[PrimeQ[n+1],b-a,b+a]}; NestList[nxt,{2,1,1},50][[All,2]] (* _Harvey P. Dale_, Dec 23 2022 *)

%o (MATLAB)

%o a(1)=1;a(2)=1;

%o for i=3:n,

%o true = isprime(n) ;

%o if true,

%o a(i)=a(i-1)-a(i-2) ;

%o else

%o a(i)=a(i-1)+a(i-2) ;

%o end

%o end

%o % isprime returns 1 if n is prime, else 0.

%o (PARI) a=vector(100);a[1]=a[2]=1;for(n=3,#a,a[n]=a[n-1]+(1-2*isprime(n))*a[n-2]); a \\ _Charles R Greathouse IV_, Jul 01 2011

%Y Cf. A010051, A000045.

%K nonn,changed

%O 1,6

%A _Pasi Airikka_, Jul 01 2011

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 24 22:17 EDT 2024. Contains 371964 sequences. (Running on oeis4.)