Climb n | C ++ program to count total number of ways to reach n - th stair with all jumps allowed ; Function to calculate leaps ; Driver code
#include <iostream> NEW_LINE int calculateLeaps ( int n ) { if ( n == 0 n == 1 ) { return 1 ; } else { int leaps = 0 ; for ( int i = 0 ; i < n ; i ++ ) leaps += calculateLeaps ( i ) ; return leaps ; } } int main ( ) { int calculateLeaps ( int ) ; std :: cout << calculateLeaps ( 4 ) << std :: endl ; return 0 ; }