Problem : 12


#include <stdio.h>

int F (int n)
{
    int g = 0;

    if (n == 1)
        return n;

    g = F (n - 1);

    if (n % 2)
        return g + n;

    return g - n;
 }


 int main ()
 {
     printf("%d\n", F (2147483647));
     return 0;
 }

// Assume this program will not crash and
// run properly, then What's the output ?
// Source : http://www.youngprogrammer.com/
Advertisements

One thought on “Problem : 12

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s