# Greetings from The On-Line Encyclopedia of Integer Sequences! http://oeis.org/ Search: id:a175458 Showing 1-1 of 1 %I A175458 #13 Feb 01 2018 03:43:36 %S A175458 0,1,3,6,2,7,13,20,28,19,29,40,52,65,79,94,110,127,109,128,148,127, %T A175458 149,172,196,221,247,274,302,331,361,392,424,457,491,526,562,599,637, %U A175458 676,716,757,799,842,886,931,977,1024,1072,1121,1171,1222,1274,1327,1381 %N A175458 a(0)=0. a(n) = a(n-1) - n, if a(n-1) - n = a (positive) prime. Otherwise a(n) = a(n-1) + n. %C A175458 Terms a(1) through a(15) match the first 15 terms of A098141. %F A175458 The only decreases are for n = 4, 9, 18, and 21. Thereafter, a(n) = n*(n+1)/2-104, so a(n)-(n+1) = n*(n-1)/2-105 = (n-15)*(n+14)/2, which is not prime (for n > 17). - _Franklin T. Adams-Watters_, May 25 2010 %p A175458 A175458 := proc(n) option remember; if n =0 then 0; else if isprime( procname(n-1)-n) then procname(n-1)-n; else procname(n-1)+n ; end if; end if; end proc: seq(A175458(n),n=0..120) ; # _R. J. Mathar_, May 28 2010 %o A175458 (PARI) r=0;vector(60,n,r=if(isprime(r-n),r-n,r+n)) \\ _Franklin T. Adams-Watters_, May 25 2010 %K A175458 nonn %O A175458 0,3 %A A175458 _Leroy Quet_, May 20 2010 %E A175458 More terms from _Franklin T. Adams-Watters_ and _R. J. Mathar_, May 25 2010 # Content is available under The OEIS End-User License Agreement: http://oeis.org/LICENSE