login
a(n) is the number of ways n can be reached in the algorithm explained in A358094 if the last operation is summation.
3

%I #26 Jan 01 2024 08:02:59

%S 1,0,1,2,2,1,0,1,1,2,3,3,2,3,3,0,2,3,1,2,2,2,2,3,3,4,4,2,3,4,3,5,5,0,

%T 3,5,2,6,6,1,3,4,2,5,5,2,5,5,2,3,3,3,5,6,4,7,7,2,3,4,3,6,6,3,5,7,5,7,

%U 7,0,2,5,3,8,8,2,5,9,6,10

%N a(n) is the number of ways n can be reached in the algorithm explained in A358094 if the last operation is summation.

%H Yifan Xie, <a href="/A358095/b358095.txt">Table of n, a(n) for n = 1..10000</a>

%F a(n) = A358096(n-2) + A358096(n-3) for n > 3.

%F a(n) = 0 if and only if n = 2 or n = 9*2^n - 2.

%e There are 3 ways to reach 11: (1*2+2)*2+3=11, (1+3)*2+3=11 and (1+2)*3+2=11.

%o (C++) #include <iostream>

%o using namespace std; int f(int x, bool y) { if(x<0) return 0; if(x==1) return 1; if(y==0) return f(x-2, 1)+f(x-3, 1); if(y==1) { if(x%6==0) return f(x/2, 0)+f(x/3, 0); if(x%6==1||x%6==5) return 0; if(x%6==2||x%6==4) return f(x/2, 0); if(x%6==3) return f(x/3, 0); } } int n; int main() { cin>>n; cout<<1<<", "; for(int i=2; i<n; i++) cout<<f(i, 0)<<", "; cout<<f(n, 0); return 0; }

%Y Cf. A358094, A358096.

%K nonn,easy

%O 1,4

%A _Yifan Xie_, Nov 01 2022