%I #21 May 07 2022 09:50:15
%S 0,1,2,7,14,29,50,95,164,304,475,824,1370,2297,3598,5906,9370,15586,
%T 23848,39227,61448,98114,151318,240098,378290,599105,916738,1454537,
%U 2261948,3543307,5448094,8486453,13088486,20669311,31151588,49081505,75209263,116597314
%N a(n) is the result of n applications of the function f on n, where f(x) = floor((3*x - 1)/2) (A001651).
%F a(n) = f^n(n) where f(n) = floor((3*n - 1)/2) = A001651(n).
%e a(0) = f^0 (0) = 0 (f not applied at all);
%e a(1) = f^1 (1) = f(1) = floor((3*1 - 1)/2) = 1;
%e a(2) = f^2 (2) = f(f(2)) = floor((3*f(2) - 1)/2) = floor((3*floor((3*2 - 1)/2) - 1)/2) = 2.
%p a:= n-> (f-> (f@@n)(n))(t-> floor((3*t-1)/2)):
%p seq(a(n), n=0..20);
%o (C++)
%o #include <iostream>
%o using namespace std;
%o // Think of unsigned int as a natural number
%o unsigned int f(unsigned int n) {
%o return (3*n - 1)/2;
%o }
%o unsigned int a(unsigned int pow, unsigned int n) {
%o if (pow == 0) return n;
%o else return a(pow-1, f(n));
%o }
%o int main() {
%o for (unsigned int n(0); n <= 20; ++n)
%o cout << a(n, n) << " ";
%o return 0;
%o }
%o (Python)
%o def f(n):
%o return (3*n - 1)//2;
%o def a(pow, n):
%o if (pow == 0): return n;
%o else: return a(pow-1, f(n));
%o l = [a(n, n) for n in range(21)];
%o (Python)
%o from functools import reduce
%o def A353215(n): return reduce(lambda x, _ : (3*x-1)//2, range(n), n) # _Chai Wah Wu_, May 07 2022
%Y Cf. A001651 (step), A353220.
%K nonn
%O 0,3
%A _Yves Daaboul_, May 01 2022
|