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.

A139391 Next odd term in Collatz trajectory with starting value n.

Original entry on oeis.org

1, 1, 5, 1, 1, 3, 11, 1, 7, 5, 17, 3, 5, 7, 23, 1, 13, 9, 29, 5, 1, 11, 35, 3, 19, 13, 41, 7, 11, 15, 47, 1, 25, 17, 53, 9, 7, 19, 59, 5, 31, 21, 65, 11, 17, 23, 71, 3, 37, 25, 77, 13, 5, 27, 83, 7, 43, 29, 89, 15, 23, 31, 95, 1, 49, 33, 101, 17, 13, 35, 107, 9, 55, 37, 113, 19, 29
Offset: 1

Views

Author

Reinhard Zumkeller, Apr 17 2008

Keywords

Crossrefs

Cf. A075677 (odd bisection).

Programs

  • Mathematica
    a[n_]:=Select[NestWhileList[If[EvenQ[#],#/2,3#+1] &,n,#>1 &],OddQ]; Prepend[Table[If[EvenQ[n],a[n][[1]],a[n][[2]]],{n,2,77}],1] (* Jayanta Basu, May 27 2013 *)
  • PARI
    a(n) = my(x = if(n%2, 3*n+1, n/2)); x/2^valuation(x, 2); \\ Michel Marcus, Feb 27 2022
  • Python
    # first formula
    def A006370(n): return 3*n+1 if n%2 else n//2
    def a(n): return x if (x := A006370(n))%2 else a(x)
    print([a(n) for n in range(1, 78)]) # Michael S. Branicky, Dec 15 2021
    
  • Python
    # fourth formula, uses A006370 above
    def A000265(n):
        while n%2 == 0: n //= 2
        return n
    def a(n): return A000265(A006370(n))
    print([a(n) for n in range(1, 78)]) # Michael S. Branicky, Dec 15 2021
    

Formula

a(n) = A006370(n) if A006370(n) is odd, otherwise a(A006370(n)).
a(n) = A006370(n) iff n mod 4 = 2;
a(A016825(n)) = A006370(A016825(n));
a(n) = A000265(A006370(n)).
a(A160967(n)) = 1. - Reinhard Zumkeller, May 31 2009
For odd n, a(n) = a(2*A350091((n-1)/2)+1). - Ruud H.G. van Tol, Dec 17 2021
Sum_{k=1..n} a(k) ~ n^2 / 3. - Amiram Eldar, Aug 26 2024
a(n) = A000265(A014682(n)). - Alan Michael Gómez Calderón, Apr 10 2025

A065883 Remove factors of 4 from n (i.e., write n in base 4, drop final zeros, then rewrite in decimal).

Original entry on oeis.org

1, 2, 3, 1, 5, 6, 7, 2, 9, 10, 11, 3, 13, 14, 15, 1, 17, 18, 19, 5, 21, 22, 23, 6, 25, 26, 27, 7, 29, 30, 31, 2, 33, 34, 35, 9, 37, 38, 39, 10, 41, 42, 43, 11, 45, 46, 47, 3, 49, 50, 51, 13, 53, 54, 55, 14, 57, 58, 59, 15, 61, 62, 63, 1, 65, 66, 67, 17, 69, 70, 71, 18, 73, 74, 75
Offset: 1

Views

Author

Henry Bottomley, Nov 26 2001

Keywords

Examples

			a(7)=7, a(14)=14, a(28)=a(4*7)=7, a(56)=a(4*14)=14, a(112)=a(4^2*7)=7.
		

Crossrefs

Cf. A214392, A235127, A350091 (drop final 2's).
Remove other factors: A000265, A038502, A132739, A244414, A242603, A004151.

Programs

  • Maple
    A065883:= n -> n/4^floor(padic:-ordp(n,2)/2):
    map(A065883, [$1..1000]); # Robert Israel, Dec 08 2015
  • Mathematica
    If[Divisible[#,4],#/4^IntegerExponent[#,4],#]&/@Range[80] (* Harvey P. Dale, Aug 31 2013 *)
  • PARI
    a(n)=n/4^valuation(n,4); \\ Joerg Arndt, Dec 09 2015
    
  • Python
    def A065883(n): return n>>((~n&n-1).bit_length()&-2) # Chai Wah Wu, Jul 09 2022

Formula

If n mod 4 = 0 then a(n) = a(n/4), otherwise a(n) = n.
Multiplicative with a(p^e) = 2^(e (mod 2)) if p = 2 and a(p^e) = p^e if p is an odd prime.
a(n) = n/4^A235127(n).
a(n) = A214392(n) if n mod 16 != 0. - Peter Kagey, Sep 02 2015
From Robert Israel, Dec 08 2015: (Start)
G.f.: x/(1-x)^2 - 3 Sum_{j>=1} x^(4^j)/(1-x^(4^j))^2.
G.f. satisfies G(x) = G(x^4) + x/(1-x)^2 - 4 x^4/(1-x^4)^2. (End)
Sum_{k=1..n} a(k) ~ (2/5) * n^2. - Amiram Eldar, Nov 20 2022
Dirichlet g.f.: zeta(s-1)*(4^s-4)/(4^s-1). - Amiram Eldar, Jan 04 2023
Showing 1-2 of 2 results.