/*********************************************************
   FIB.C using a Microsoft Visual C++ version 1.0 Compiler
*********************************************************/
#include <windows.h>

/* standard DLL start-up function */

int FAR PASCAL LibMain (HANDLE hInstance, WORD wDataSeg,
                        WORD wHeapSize, LPSTR lpszCmdLine)
{
    /* if local (moveable) heap allocated, unlock it */
    if (wHeapSize > 0)
        UnlockData (0);
    return (1);
}

/* traditional DLL exit function */

int FAR PASCAL _export
WEP (int nParam)
{
    return (1);
}

/* Compute the nth Fibonacci number using recursion */

long
fibiter (long a, long b, long c)
{
    if (c <= 0L) return b;
    else return fibiter (a + b, a, c - 1);
}

void FAR PASCAL
fib (long FAR *n)
{
    *n = fibiter(1, 0, *n);
}
