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!)
A329130 a(0)=0; for any n >= 0, if a(n) > n then a(n+1) = a(n) - n, otherwise a(n+1) = a(n) + k, where k is the total number of terms a(m) <= m with m <= n. 1
0, 1, 3, 1, 4, 8, 3, 8, 1, 7, 14, 4, 12, 21, 8, 18, 3, 14, 26, 8, 21, 1, 15, 30, 7, 23, 40, 14, 32, 4, 23, 43, 12, 33, 55, 21, 44, 8, 32, 57, 18, 44, 3, 30, 58, 14, 43, 73, 26, 57, 8, 40, 73, 21, 55, 1, 36, 72, 15, 52, 90 (list; graph; refs; listen; history; text; internal format)
OFFSET
0,3
COMMENTS
Values where a(n) = n appear to be the values of A027941.
LINKS
FORMULA
a(n+1) = a(n) + I, if n >= a(n) ('I' is the next consecutive integer not yet added);
= a(n) - n, if n < a(n).
From Yan Sheng Ang, May 20 2020: (Start)
a(A004957(n)) = a(n). Hence it follows that (writing F(n) = A000045(n)):
a(F(2*n)-1) = F(2*n) for n > 1;
a(F(2*n)) = 1;
a(F(2*n+1)-1) = F(2*n+1)-1 (as noted above);
a(F(2*n+1)) = F(2*n+2);
a(F(2*n+1)+1) = F(2*n) for n > 1.
(End)
EXAMPLE
For n = 0, a(0) = 0 0 >= a(0)
n = 1, a(1) = a(0) + 1 = 1, 1 >= a(1), I = 1
n = 2, a(2) = a(1) + 2 = 3, 2 < a(2), I = 2
n = 3, a(3) = a(2) - 2 = 1, 3 >= a(3)
n = 4, a(4) = a(3) + 3 = 4, 4 >= a(4), I = 3
n = 5, a(5) = a(4) + 4 = 8, 5 < a(5), I = 4
n = 6, a(6) = a(5) - 5 = 3, 6 >= a(6)
n = 7, a(7) = a(6) + 5 = 8, 7 < a(7), I = 5
n = 8, a(8) = a(7) - 7 = 1, 8 >= a(8)
n = 9, a(9) = a(8) + 6 = 7, 9 >= a(9), I = 6
n = 10, a(10)= a(9) + 7 = 14, 10< a(10), I = 7
n = 11, a(11)= a(10)- 10= 4, 11>= a(11)
n = 12, a(12)= a(11)+ 8 = 12, 12>= a(12), I = 8
.
.
.
PROG
(C)
#include<stdio.h>
void seq(int terms)
{int n = 0; int i = 0; int a = 0; int c = 0;
while (n <= terms)
{
if (c)
{int N = n - 1;
a -= N;
printf("%d\n", a); }
else
{a += i;
printf("%d\n", a);
i++; }
if (a > n)
{c = 1; }
else
{c = 0; }
n++;
}
}
int main(void)
{
seq(1000);
}
(PARI) v=k=0; for (n=0, 69, print1 (v, ", "); v=if (v>n, v-n, v+k++)) \\ Rémy Sigrist, Nov 06 2019
CROSSREFS
Sequence in context: A193605 A193667 A205878 * A057049 A245672 A303029
KEYWORD
look,easy,nonn
AUTHOR
James Marjamaa, Nov 05 2019
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 26 03:28 EDT 2024. Contains 371989 sequences. (Running on oeis4.)