[ create a new paste ] login | about

Link: http://codepad.org/Rqfzo3CE    [ raw code | output | fork ]

C, pasted on Jul 30:
#include <stdio.h>

int succ_helper(int value, int max, int iteration_number)
{
    if (iteration_number >= max) return value;

    printf("%d: %d - %d\n", iteration_number, value, max);

    return succ_helper(value + 1, max, iteration_number + 1);
}

int succ(int value, int max)
{
    succ_helper(value, max, 0);
}

int main(void)
{
    int start = 9; // Your a
    int count = 6; // Your b

    int sum = succ(start, count);

    return 0;
}


Output:
1
2
3
4
5
6
0: 9 - 6
1: 10 - 6
2: 11 - 6
3: 12 - 6
4: 13 - 6
5: 14 - 6


Create a new paste based on this one


Comments: