#include<iostream> using namespace std; int f(int stepp){ if(stepp==1){ return 1; } else if(stepp==2){ return 2; } else if(stepp==3){ return 3; } else { return f(stepp-1)+f(stepp-2)+f(stepp-3); } } int main(){ int step; cin>>step; cout<<f(step); return 0; }
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up