// Recursive_math.cpp : Defines the entry point for the console application. // #include "stdafx.h" float a = 1.0; float b = 1.0; float f0 = 1.0; float f1 = 1.0; float find_f (int n); int _tmain(int argc, _TCHAR* argv[]) { int i; for(i=1; i <= 20; i++) printf("f_%2d = %15.3f\n", i, find_f(i)); return 0; } float find_f (int n) { float result = 0; if (n == 0) result = f0; else if (n == 1) result = f1; else if (n == 2) result = a*f1 + b*f0; else if (n == 3) result = a*find_f(2) + b*f1; else result = a*find_f(n-1) + b*find_f(n-2); return(result); }