#include <stdlib.h>
#include <stdio.h>

{TYPE} sum_forward(int N) {
    {TYPE} sum = 0;

    for( int i = 1; i <= N; i++ )
        sum += 1.0 / i;

    return sum;
}

{TYPE} sum_backward(int N) {
    {TYPE} sum = 0;

    for( int i = N; i; i-- )
        sum += 1.0 / i;

    return sum;
}

int main(void) {
    puts("Using type {TYPE}.");

    puts("Forward summation:");
    printf("N = 1e8: %f\n", sum_forward(1e8));
    printf("N = 2e8: %f\n", sum_forward(2e8));

    puts("Backward summation:");
    printf("N = 1e8: %f\n", sum_backward(1e8));
    printf("N = 2e8: %f\n", sum_backward(2e8));

    return 0;
}
