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.

A327491 a(0) = 0. If 4 divides n then a(n) = valuation(n, 2) else a(n) = (n mod 2) + 1.

Original entry on oeis.org

0, 2, 1, 2, 2, 2, 1, 2, 3, 2, 1, 2, 2, 2, 1, 2, 4, 2, 1, 2, 2, 2, 1, 2, 3, 2, 1, 2, 2, 2, 1, 2, 5, 2, 1, 2, 2, 2, 1, 2, 3, 2, 1, 2, 2, 2, 1, 2, 4, 2, 1, 2, 2, 2, 1, 2, 3, 2, 1, 2, 2, 2, 1, 2, 6, 2, 1, 2, 2, 2, 1, 2, 3, 2, 1, 2, 2, 2, 1, 2, 4, 2, 1, 2, 2, 2, 1, 2
Offset: 0

Views

Author

Peter Luschny, Sep 27 2019

Keywords

Examples

			Seen as an irregular table for n >= 1:
  2,
  1, 2,
  2, 2, 1, 2,
  3, 2, 1, 2, 2, 2, 1, 2,
  4, 2, 1, 2, 2, 2, 1, 2, 3, 2, 1, 2, 2, 2, 1, 2,
  5, 2, 1, 2, 2, 2, 1, 2, 3, 2, 1, 2, 2, 2, 1, 2, 4, 2, 1, 2, ....
		

Crossrefs

Programs

  • Maple
    A327491 := n -> if n = 0 then 0
    elif 0 = irem(n, 4) then padic[ordp](n, 2)
    elif 0 = irem(n, 2) then 1 else 2 fi:
    seq(A327491(n), n=0..87);
  • Mathematica
    a[0] = 0; a[n_] := If[Divisible[n, 4], IntegerExponent[n, 2], Mod[n, 2] + 1]; Array[a, 100, 0] (* Amiram Eldar, Aug 30 2024 *)
  • PARI
    a(n)={if(n==0, 0, if(n%4, n%2 + 1, valuation(n,2)))} \\ Andrew Howroyd, Sep 28 2019
  • SageMath
    def A327491(n):
        if n == 0: return 0
        if 4.divides(n): return valuation(n, 2)
        return n % 2 + 1
    print([A327491(n) for n in (0..87)])
    

Formula

a(0) = 0; if n is odd then a(n) = 2, otherwise a(n) = A007814(n). - Andrey Zabolotskiy, Jan 08 2024
Asymptotic mean: Limit_{m->oo} (1/m) * Sum_{k=1..m} a(k) = 2. - Amiram Eldar, Aug 30 2024