aboutsummaryrefslogtreecommitdiff
path: root/tests/functional/66_go_upstairs.sy
blob: f47b317d734ffcdfdb695097a7f3bf5242223202 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
int climbStairs(int n) {
    if(n < 4)
        return n;
    int dp[10];
    dp[0] = 0;
    dp[1] = 1;
    dp[2] = 2;
    int i;
    i = 3;
    while(i<n+1){
        dp[i] = dp[i-1] + dp[i-2];
        i = i + 1;
    }
    return dp[n];
}
int main(){
    int res;
    int n;
    n=5;
    res = climbStairs(n);
    return res;
}