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.

Showing 1-2 of 2 results.

A357610 Start with x = 3 and repeat the map x -> floor(n/x) + (n mod x) until an x occurs that has already appeared, then that is a(n).

Original entry on oeis.org

1, 2, 3, 2, 3, 3, 3, 4, 3, 4, 3, 3, 5, 6, 3, 6, 5, 3, 7, 5, 3, 8, 7, 3, 9, 6, 3, 10, 9, 3, 11, 8, 3, 12, 5, 3, 13, 10, 3, 14, 9, 3, 15, 11, 3, 16, 11, 3, 17, 5, 3, 18, 5, 3, 19, 12, 3, 20, 11, 3, 21, 14, 3, 22, 5, 3, 23, 8, 3, 24, 15, 3, 25, 14, 3, 26, 17, 3, 27, 5, 3, 28, 11, 3, 29, 18, 3, 30, 9
Offset: 1

Views

Author

J. M. Bergot and Robert Israel, Oct 06 2022

Keywords

Comments

1, 2 and the third column of A357554.

Examples

			a(4) = 2 because we have 3 -> floor(4/3) + (4 mod 3) = 2 -> floor(4/2) + (4 mod 2) = 2.
		

Crossrefs

Cf. A357554.

Programs

  • Maple
    g:= proc(n, k) local x, S;
      S:= {k};
      x:= k;
      do
         x:= iquo(n, x) + irem(n, x);
         if member(x, S) then return x fi;
         S:= S union {x};
      od
    end proc:
    seq(g(n,3), n=1..100);
  • Mathematica
    T[n_, k_] := Module[{x, S}, S = {k}; x = k; While[True, x = Total@QuotientRemainder[n, x]; If[MemberQ[S, x], Return[x]]; S = S~Union~{x}]];
    a[n_] := T[n, 3];
    Table[a[n], {n, 1, 100}] (* Jean-François Alcover, Oct 17 2022, after Maple code *)
  • Python
    def a(n):
        seen, x = set(), 3
        while x not in seen: seen.add(x); q, r = divmod(n, x); x = q + r
        return x
    print([a(n) for n in range(1, 90)]) # Michael S. Branicky, Oct 06 2022~

Formula

a(n) = 3 if n is divisible by 3.
a(3*k+1) = k+1.
a(15*k+5) = 5 for k >= 1.
a(15*k+11) = 3*k+3.
a(255*k+137) = 15*k+9 for k >= 1.

A358052 Triangular array read by rows. For T(n,k) where 1 <= k <= n, start with x = k and repeat the map x -> floor(n/x) + (n mod x) until an x occurs that has already appeared. The number of applications of the map is T(n,k).

Original entry on oeis.org

1, 2, 2, 2, 1, 2, 2, 1, 2, 2, 2, 2, 1, 3, 2, 2, 2, 2, 3, 3, 2, 2, 2, 1, 1, 2, 3, 2, 2, 2, 3, 2, 3, 4, 3, 2, 2, 2, 1, 2, 1, 3, 2, 3, 2, 2, 2, 2, 1, 2, 3, 2, 3, 3, 2, 2, 2, 2, 3, 2, 1, 3, 4, 3, 3, 2, 2, 2, 2, 2, 3, 2, 3, 4, 3, 3, 3, 2, 2, 2, 2, 1, 1, 3, 1, 4, 2, 2, 3, 3, 2, 2, 2, 4, 3, 3, 3, 2, 3
Offset: 1

Views

Author

J. M. Bergot and Robert Israel, Oct 27 2022

Keywords

Comments

T(n,k) = 1 if k^2 >= n > k and k-1 divides n-k.
If A234575(n,k) = j then either T(n,k) = T(n,j)+1 and A357554(n,k) = A357554(n,j), or T(n,k) = T(n,j), A357554(n,k) = k and A357554(n,j) = j.

Examples

			For T(13,2) we have 2 -> floor(13/2) + (13 mod 2) = 7 -> floor(13/7) + (13 mod 7) = 7.  That is two applications of the map so T(13,2) = 2.
Triangle starts:
  1;
  2, 2;
  2, 1, 2;
  2, 1, 2, 2;
  2, 2, 1, 3, 2;
  2, 2, 2, 3, 3, 2;
  2, 2, 1, 1, 2, 3, 2;
  2, 2, 3, 2, 3, 4, 3, 2;
  2, 2, 1, 2, 1, 3, 2, 3, 2;
  2, 2, 2, 1, 2, 3, 2, 3, 3, 2;
		

Crossrefs

Programs

  • Maple
    f:= proc(n, k) local x, S,count;
      S:= {k};
      x:= k;
      for count from 1 do
         x:= iquo(n, x) + irem(n, x);
         if member(x, S) then return count fi;
         S:= S union {x};
      od
    end proc:
    for n from 1 to 20 do seq(f(n, k), k=1..n) od;
  • Mathematica
    f[n_, k_] := Module[{x, S, count}, S = {k}; x = k; For[count = 1, True, count++, x = Quotient[n, x] + Mod[n, x]; If[MemberQ[S, x], Return[count]]; S = S~Union~{x}]];
    Table[f[n, k], {n, 1, 20}, {k, 1, n}] // Flatten (* Jean-François Alcover, Jan 29 2023, after Maple code *)
Showing 1-2 of 2 results.