cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A281367 "Nachos" sequence based on triangular numbers.

This page as a plain text file.
%I A281367 #23 Apr 11 2024 04:52:15
%S A281367 1,2,3,1,2,3,4,2,3,1,2,3,4,2,3,4,5,3,4,1,2,3,4,2,3,4,5,3,4,2,3,4,5,3,
%T A281367 1,2,3,4,2,3,4,5,3,4,2,3,4,5,3,4,5,6,4,5,2,1,2,3,4,2,3,4,5,3,4,2,3,4,
%U A281367 5,3,4,5,6,4,5,2,3,4,5,3,4,5,6,1,2,3,4,2,3,4,5,3,4,2,3,4,5,3,4
%N A281367 "Nachos" sequence based on triangular numbers.
%C A281367 The nachos sequence based on a sequence of positive numbers S starting with 1 is defined as follows: To find a(n) we start with a pile of n nachos.
%C A281367 During each phase, we successively remove S(1), then S(2), then S(3), ..., then S(i) nachos from the pile until fewer than S(i+1) remain. Then we start a new phase, successively removing S(1), then S(2), ..., then S(j) nachos from the pile until fewer than S(j+1) remain. Repeat. a(n) is the number of phases required to empty the pile.
%C A281367 Suggested by the Fibonachos sequence A280521, which is the case when S is 1,1,2,3,5,8,13,... (A000045).
%C A281367 If S = 1,2,3,4,5,... we get A057945.
%C A281367 If S = 1,2,3,5,7,11,... (A008578) we get A280055.
%C A281367 If S = triangular numbers we get the present sequence.
%C A281367 If S = squares we get A280053.
%C A281367 If S = powers of 2 we get A100661.
%C A281367 More than the usual number of terms are shown in order to distinguish this sequence from A104246.
%H A281367 Lars Blomberg, <a href="/A281367/b281367.txt">Table of n, a(n) for n = 1..10000</a>
%H A281367 Reddit user Teblefer, <a href="https://www.reddit.com/r/math/comments/5lxh3c">Fibonachos</a>
%e A281367 If n = 14, in the first phase we successively remove 1, then 3, then 6 nachos, leaving 4 in the pile. The next triangular number is 10, which is bigger than 4, so we start a new phase. We remove 1, then 3 nachos, and now the pile is empty. There were two phases, so a(14)=2.
%p A281367 S:=[seq(i*(i+1)/2,i=1..1000)];
%p A281367 phases := proc(n) global S; local a,h,i,j,ipass;
%p A281367 a:=1; h:=n;
%p A281367 for ipass from 1 to 100 do
%p A281367 for i from 1 to 100 do
%p A281367 j:=S[i];
%p A281367 if j>h then a:=a+1; break; fi;
%p A281367 h:=h-j;
%p A281367 if h=0 then return(a); fi;
%p A281367 od;
%p A281367 od;
%p A281367 return(-1);
%p A281367 end;
%p A281367 t1:=[seq(phases(i),i=1..1000)];
%p A281367 # 2nd program
%p A281367 A281367 := proc(n)
%p A281367     local a,nres,i ;
%p A281367     a := 0 ;
%p A281367     nres := n;
%p A281367     while nres > 0 do
%p A281367         for i from 1 do
%p A281367             if A000292(i) > nres then
%p A281367                 break;
%p A281367             end if;
%p A281367         end do:
%p A281367         nres := nres-A000292(i-1) ;
%p A281367         a := a+1 ;
%p A281367     end do:
%p A281367     a ;
%p A281367 end proc:
%p A281367 seq(A281367(n),n=1..80) ; # _R. J. Mathar_, Mar 05 2017
%t A281367 tri[n_] := n (n + 1) (n + 2)/6;
%t A281367 A281367[n_] := Module[{a = 0, nres = n, i}, While[nres > 0, For[i = 1, True, i++, If[tri[i] > nres, Break[]]]; nres -= tri[i-1]; a++]; a];
%t A281367 Table[A281367[n], {n, 1, 99}] (* _Jean-François Alcover_, Apr 11 2024, after _R. J. Mathar_ *)
%Y A281367 Cf. A000045, A008578, A280521, A057945, A100661, A280055.
%Y A281367 For indices of first occurrences of 1,2,3,4,... see A281368.
%Y A281367 Different from A104246.
%K A281367 nonn
%O A281367 1,2
%A A281367 _N. J. A. Sloane_, Jan 30 2017