OFFSET
0,2
COMMENTS
See A317640 for another definition of this problem.
LINKS
Harvey P. Dale, Table of n, a(n) for n = 0..1000
David Barina, 7x+-1: Close Relative of Collatz Problem, arXiv:1807.00908 [math.NT], 2018.
K. Matthews, David Barina's 7x+1 conjecture.
Index entries for linear recurrences with constant coefficients, signature (0, 1, 0, 1, 0, -1).
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)
EXAMPLE
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.
MATHEMATICA
Table[Which[Mod[n, 4]==1, (7n+1)/4, Mod[n, 4]==3, (7n-1)/4, True, n/2], {n, 0, 70}] (* Harvey P. Dale, Oct 25 2025 *)
(* Alternative: *)
LinearRecurrence[{0, 1, 0, 1, 0, -1}, {0, 2, 1, 5, 2, 9}, 80] (* Harvey P. Dale, Oct 25 2025 *)
PROG
(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
CROSSREFS
KEYWORD
nonn,easy
AUTHOR
David Barina, Sep 06 2018
STATUS
approved
