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!)
A332267 a(1) = 1; a(2) = 2; for n > 2, if a(n-1) > a(n-2) then a(n) = a(n-1) - a(n-2), otherwise a(n) = number of occurrences of a(n-1). 0

%I #17 Jun 19 2020 21:50:12

%S 1,2,1,2,1,3,2,3,1,4,3,3,4,1,5,4,3,5,2,4,2,5,3,6,3,7,4,5,1,6,5,5,6,1,

%T 7,6,4,6,2,6,4,7,3,8,5,7,2,7,5,8,3,9,6,7,1,8,7,7,8,1,9,8,5,9,4,8,4,9,

%U 5,10,5,11,6,8,2,8,6,9,3,10,7,9,2,9,7

%N a(1) = 1; a(2) = 2; for n > 2, if a(n-1) > a(n-2) then a(n) = a(n-1) - a(n-2), otherwise a(n) = number of occurrences of a(n-1).

%e a(9) = a(8) - a(7) = 3-2 = 1. The number of occurrences of 1 up to that point is 4, so a(10) = 4.

%o (PARI) a=[1,2];for(n=2,99,a=concat(a,if(a[n]>a[n-1],a[n]-a[n-1],sum(i=1,n,a[i]==a[n]))));a \\ _M. F. Hasler_, May 22 2020, brackets fixed by _David A. Corneth_, May 22 2020

%o (PARI) first(n) = {n = max(n, 2); res = vector(n); freqs = vector(2); res[1] = 1; res[2] = 2; freqs[1] = 1; freqs[2] = 1; for(i = 3, n, d = res[i-1] - res[i-2]; if(d > 0, res[i] = d; freqs[d]++ , fr = freqs[res[i-1]]; res[i] = fr; if(fr > #freqs, freqs = concat(freqs, vector(fr - #freqs)); ); freqs[fr]++ ) ); res } \\ _David A. Corneth_, May 22 2020

%K nonn,easy,look

%O 1,2

%A _Ali Sada_, May 04 2020

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 July 13 15:08 EDT 2024. Contains 374284 sequences. (Running on oeis4.)