OFFSET
1,7
COMMENTS
In this sequence, a subsequence is considered ascending for as long as a (3*n + 1) / 2 step is required.
LINKS
Douglas Boffey, Table of n, a(n) for n = 1..20000
Douglas Boffey, Code used for generating b-file
FORMULA
a(2^n) = 0.
a((2^n*(2*x+1)-1) * 2^y) = a(3^n*(2*x+1)-1) + 1, where x, y >= 0.
EXAMPLE
a(9) = 4, viz.
9->14;
14->7->11->17->26;
26->13->20;
20->10->5->8.
PROG
(C) /* A007814 */
int num_clear_bits(unsigned n) {
if (n == 0)
return -1;
return log2(n & -n);
}
int A346965(unsigned n) {
int x;
int result = 0;
n >>= num_clear_bits(n);
while (n > 1) {
x = num_clear_bits(n + 1);
n = ((n >> x) + 1) * pow(3, x) - 1;
n >>= num_clear_bits(n);
++result;
}
return result;
}
CROSSREFS
KEYWORD
nonn
AUTHOR
Douglas Boffey, Aug 09 2021
STATUS
approved