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!)
A365203 a(1) = 1; a(n) = a(n - 1) + n if a(n - 1) < n, a(n) = n^2 if a(n - 1) = n, a(n) = a(n - 1)/n if a(n - 1) > n and a(n - 1) == 0 (mod n), otherwise a(n) = a(n - 1) - n. 2
1, 3, 9, 5, 25, 19, 12, 4, 13, 3, 14, 2, 15, 1, 16, 256, 239, 221, 202, 182, 161, 139, 116, 92, 67, 41, 14, 42, 13, 43, 12, 44, 11, 45, 10, 46, 9, 47, 8, 48, 7, 49, 6, 50, 5, 51, 4, 52, 3, 53, 2, 54, 1, 55, 3025, 2969, 2912, 2854, 2795, 2735, 2674, 2612, 2549 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
LINKS
EXAMPLE
a(2) = a(1) + 2 = 3, since a(1) = 1 < 2.
a(3) = 3^2 = 9, since a(2) = 2.
a(4) = a(3) - 4 = 5, since a(3) = 9 > 4 and 9 != 0 (mod 4).
a(83) = a(82)/83 = 14, a(82) = 1162 > 83 and 1162 == 0 (mod 83).
MAPLE
A365203 := proc(n) option remember;
if n = 1 then 1;
elif procname(n - 1) < n then procname(n - 1) + n;
elif n = procname(n - 1) then n*n;
elif irem(procname(n - 1), n) = 0 then procname(n - 1)/n;
else procname(n - 1) - n;
end if;
end proc;
seq(A365203(n), n = 1 .. 10000);
PROG
(PARI) lista(nn) = my(va = vector(nn)); va[1] = 1; for (n=2, nn, my(vs = sign(va[n-1] - n)); if (vs<0, va[n] = va[n-1] + n, if (vs==0, va[n] = n^2, if ((va[n-1] % n)== 0, va[n] = va[n-1]/n, va[n] = va[n-1] - n))); ); va; \\ Michel Marcus, Aug 27 2023
(Python)
from itertools import count, islice
def A365203_gen(): # generator of terms
yield (a:=1)
for n in count(2):
if a<n:
b = a+n
elif a==n:
b = n**2
elif a%n:
b = a-n
else:
b = a//n
yield (a:=b)
A365203_list = list(islice(A365203_gen(), 30)) # Chai Wah Wu, Sep 23 2023
CROSSREFS
Sequence in context: A262024 A252117 A103934 * A186814 A077384 A122943
KEYWORD
easy,nonn
AUTHOR
Felix Huber, Aug 26 2023
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 27 02:17 EDT 2024. Contains 372004 sequences. (Running on oeis4.)