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!)
A135025 Let b(1) = 2; and for n>= 2, if b(n-1) < prime(n) then b(n) = b(n-1) + prime(n) otherwise b(n) = b(n-1) - prime(n). The sequence gives the indices n where b(n-1) < b(n) < b(n+1). 5

%I #29 Aug 16 2022 07:39:47

%S 4,9,22,57,146,367,946,2507,6634,17777,48522,133107,369020,1028405,

%T 2880288,8100949,22877146,64823569,184274932,525282741,1501215194,

%U 4299836187,12340952050,35486796313,102220582466,294917666855,852123981582,2465458792769

%N Let b(1) = 2; and for n>= 2, if b(n-1) < prime(n) then b(n) = b(n-1) + prime(n) otherwise b(n) = b(n-1) - prime(n). The sequence gives the indices n where b(n-1) < b(n) < b(n+1).

%C The b sequence, prefixed by 0, is A008348. The low points in b are 1 less than the terms of the present sequence, and are given in A309226. - _N. J. A. Sloane_, Aug 31 2019

%e b(1) = 2

%e b(2) = 5

%e b(3) = 0

%e b(4) = 7

%e b(5) = 18

%e b(3) < b(4) < b(5), so 4 is the first term of the sequence.

%p B := proc(n) option remember ; if n = 1 then 2; else if procname(n-1)-ithprime(n) < 0 then procname(n-1)+ithprime(n) ; else procname(n-1)-ithprime(n) ; fi; fi; end: A135025 := proc(n) option remember ; if n = 1 then 4; else for a from procname(n-1)+1 do if B(a-1) < B(a) and B(a) < B(a+1) then RETURN(a) ; fi; od: fi; end: for n from 1 do printf("%d,\n",A135025(n)) ; od: # _R. J. Mathar_, Feb 06 2009

%t B[n_] := B[n] = If[n == 1, 2, If[B[n-1] - Prime[n] < 0, B[n-1] + Prime[n], B[n-1] - Prime[n]]];

%t a[n_] := a[n] = If[n == 1, 4, For[k = a[n-1]+1, True, k++, If[B[k-1] < B[k] && B[k] < B[k+1], Return[k]]]];

%t Table[Print[n, " ", a[n]]; a[n], {n, 1, 16}] (* _Jean-François Alcover_, Aug 16 2022, after _R. J. Mathar_ *)

%Y Cf. A008348, A135026, A309226.

%K nonn,more

%O 1,1

%A Lior Deutsch (liorde(AT)gmail.com), Feb 10 2008

%E New term added by Lior Deutsch (liorde(AT)gmail.com), Oct 17 2008

%E Definition corrected and entry revised by _Robert Israel_, _Michel Marcus_, and _N. J. A. Sloane_, Sep 29 2014

%E a(17)-a(28) from _Giovanni Resta_, Oct 02 2019

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 23 18:16 EDT 2024. Contains 371916 sequences. (Running on oeis4.)