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.

User: David Barina

David Barina's wiki page.

David Barina has authored 4 sequences.

A318972 The 7x+-1 function ("shortcut" definition): a(n) = (7n+1)/4 if n == +1 (mod 4), a(n) = (7n-1)/4 if n == -1 (mod 4), otherwise a(n) = n/2.

Original entry on oeis.org

0, 2, 1, 5, 2, 9, 3, 12, 4, 16, 5, 19, 6, 23, 7, 26, 8, 30, 9, 33, 10, 37, 11, 40, 12, 44, 13, 47, 14, 51, 15, 54, 16, 58, 17, 61, 18, 65, 19, 68, 20, 72, 21, 75, 22, 79, 23, 82, 24, 86, 25, 89, 26, 93, 27, 96, 28, 100, 29, 103, 30, 107, 31, 110, 32, 114, 33, 117, 34, 121
Offset: 0

Author

David Barina, Sep 06 2018

Keywords

Comments

See A317640 for another definition of this problem.

Examples

			a(3) = 5 because 3 == -1 (mod 4), and thus (7*3 - 1)/4 results in 5.
a(5) = 9 because 5 == +1 (mod 4), and thus (7*5 + 1)/4 results in 9.
		

Crossrefs

Cf. A014682 (3x+1 equivalent), A317640.

Programs

  • C
    int a(int n) {
        switch(n%4) {
            case 1: return (7*n+1)/4;
            case 3: return (7*n-1)/4;
            default: return n/2;
        }
    }
    
  • PARI
    a(n) = my(m=n%4); if (m==1, (7*n+1)/4, if (m==3, (7*n-1)/4, n/2)); \\ Michel Marcus, Sep 06 2018
    
  • Python
    from _future_ import division
    def A318972(n):
        return (7*n+1)//4 if n % 4 == 1 else (7*n-1)//4 if n % 4 == 3 else n//2 # Chai Wah Wu, Nov 09 2018

Formula

a(n) = a(a(2*n))
From Chai Wah Wu, Nov 09 2018: (Start)
a(n) = a(n-2) + a(n-4) - a(n-6) for n > 5.
G.f.: x*(2*x^4 + x^3 + 3*x^2 + x + 2)/(x^6 - x^4 - x^2 + 1). (End)

A318489 Number of steps to reach a lower number than starting value in 7x+-1 problem, or 0 if never reached.

Original entry on oeis.org

0, 1, 12, 1, 8, 1, 4, 1, 4, 1, 42, 1, 8, 1, 4, 1, 4, 1, 23, 1, 20, 1, 4, 1, 4, 1, 12, 1, 16, 1, 4, 1, 4, 1, 282, 1, 12, 1, 4, 1, 4, 1, 229, 1, 50, 1, 4, 1, 4, 1, 8, 1, 35, 1, 4, 1, 4, 1, 8, 1, 50, 1, 4, 1, 4, 1, 46, 1, 8, 1, 4, 1, 4, 1, 225, 1, 8, 1, 4, 1, 4, 1, 35, 1, 16, 1, 4, 1, 4, 1, 46, 1, 27, 1, 4, 1, 4, 1, 16
Offset: 1

Author

David Barina, Aug 27 2018

Keywords

Comments

The least positive k for which the iterate A317640^k(n) < n.
Also called the dropping time, glide, or stopping time.
a(2n) = 1.

Examples

			a(5) = 8 because the trajectory is (5, 36, 18, 9, 64, 32, 16, 8, 4, 2, 1, ...) and the first lower number is 4. Thus 8 steps to reach the value 4 starting from the value 5.
		

Crossrefs

Cf. A317640 (7x+-1 function), A102419 (3x+1 equivalent).

Programs

  • C
    int a(int n0) {
            if( n0 == 1 ) return 0;
            int s = 0;
            for(int n = n0; n >= n0; s++) {
                    switch(n%4) {
                            case 1: n = 7*n+1; break;
                            case 3: n = 7*n-1; break;
                            default: n = n/2;
                    }
            }
            return s;
    }
    
  • PARI
    a7(n) = {my(m=(n+2)%4-2); if(m%2, 7*n + m, n/2)};
    a(n) = if (n==1, 0, my(nb=1, m=n, nm); while((nm=a7(m)) >= n, m = nm; nb++); nb); \\ Michel Marcus, Aug 28 2018

A317753 Number of steps to reach 1 in 7x+-1 problem, or -1 if 1 is never reached.

Original entry on oeis.org

0, 1, 13, 2, 10, 14, 18, 3, 7, 11, 53, 15, 19, 19, 23, 4, 27, 8, 50, 12, 73, 54, 16, 16, 58, 20, 20, 20, 43, 24, 24, 5, 47, 28, 325, 9, 70, 51, 32, 13, 13, 74, 272, 55, 55, 17, 17, 17, 276, 59, 40, 21, 40, 21, 21, 21, 63, 44, 63
Offset: 1

Author

David Barina, Aug 06 2018

Keywords

Comments

The 7x+-1 problem is as follows. Start with any natural number n. If 4 divides n-1, multiply it by 7 and add 1; if 4 divides n+1, multiply it by 7 and subtract 1; otherwise divide it by 2. The 7x+-1 problem concerns the question whether we always reach 1.
The number of steps to reach 1 is also called the total stopping time.
Also the least positive k for which the iterate A317640^k(n) = 1.

Examples

			a(5)=10 because the trajectory of 5 is (5, 36, 18, 9, 64, 32, 16, 8, 4, 2, 1).
		

Crossrefs

Cf. A317640 (7x+-1 function), A006577 (3x+1 equivalent).

Programs

  • C
    int a(int n) {
            int s = 0;
            while( n != 1 ) {
                    switch(n%4) {
                            case 1: n = 7*n+1; break;
                            case 3: n = 7*n-1; break;
                            default: n = n/2;
                    }
                    s++;
            }
            return s;
    }
    
  • Mathematica
    f[n_] := Switch[Mod[n, 4], 0, n/2, 1, 7 n + 1, 2, n/2, 3, 7 n - 1]; a[n_] := Length@NestWhileList[f, n, # > 1 &] - 1; Array[a, 70] (* Robert G. Wilson v, Aug 07 2018 *)
  • PARI
    a(n) = my(nb=0); while(n != 1, if (!((n-1)%4), n = 7*n+1, if (!((n+1)%4), n = 7*n-1, n = n/2)); nb++); nb; \\ Michel Marcus, Aug 06 2018

A317640 The 7x+-1 function: a(n) = 7n+1 if n == +1 (mod 4), a(n) = 7n-1 if n == -1 (mod 4), otherwise a(n) = n/2.

Original entry on oeis.org

0, 8, 1, 20, 2, 36, 3, 48, 4, 64, 5, 76, 6, 92, 7, 104, 8, 120, 9, 132, 10, 148, 11, 160, 12, 176, 13, 188, 14, 204, 15, 216, 16, 232, 17, 244, 18, 260, 19, 272, 20, 288, 21, 300, 22, 316, 23, 328, 24, 344, 25, 356, 26, 372, 27, 384, 28, 400, 29, 412, 30, 428, 31, 440, 32, 456, 33
Offset: 0

Author

David Barina, Aug 02 2018

Keywords

Comments

The 7x+-1 problem is as follows. Start with any natural number n. If 4 divides n-1, multiply it by 7 and add 1; if 4 divides n+1, multiply it by 7 and subtract 1; otherwise divide it by 2. The 7x+-1 problem concerns the question whether we always reach 1.

Examples

			a(3)=20 because 3 == -1 (mod 4), and thus 7*3 - 1 results in 20.
a(5)=36 because 5 == +1 (mod 4), and thus 7*5 + 1 results in 36.
		

Crossrefs

Cf. A006370.

Programs

  • C
    int a(int n) {
        switch(n%4) {
            case 1: return 7*n+1;
            case 3: return 7*n-1;
            default: return n/2;
        }
    }
    
  • Mathematica
    Array[Which[#2 == 1, 7 #1 + 1, #2 == 3, 7 #1 - 1, True, #1/2] & @@ {#, Mod[#, 4]} &, 67, 0] (* Michael De Vlieger, Aug 02 2018 *)
  • PARI
    a(n)={my(m=(n+2)%4-2); if(m%2, 7*n + m, n/2)} \\ Andrew Howroyd, Aug 02 2018
    
  • PARI
    concat(0, Vec(x*(8 + x + 12*x^2 + x^3 + 8*x^4) / ((1 - x)^2*(1 + x)^2*(1 + x^2)) + O(x^70))) \\ Colin Barker, Aug 03 2018

Formula

a(n) = a(a(2*n)).
From Colin Barker, Aug 03 2018: (Start)
G.f.: x*(8 + x + 12*x^2 + x^3 + 8*x^4) / ((1 - x)^2*(1 + x)^2*(1 + x^2)).
a(n) = a(n-2) + a(n-4) - a(n-6) for n>5.
(End)