All pastes #10930 Raw Edit

w00t w00t

public cpp v1 · immutable
#10930 ·published 2005-05-04 19:28 UTC
rendered paste body
#include <iostream>using namespace std;int main(){	int previous1, previous2, current, counter = 0, nthfibonacci;	cout << "enter the first two fibonacci numbers" << endl;	cin >> previous1 >> previous2;	cout << endl << "enter the position of your number" << endl;	cin >> nthfibonacci;	if (nthfibonacci < 0)	{		while (counter > nthfibonacci)		{			current = previous2 - previous1;			previous2 = previous1;			previous1 = current;			counter--;		}	}	else	{		while (counter+1 < nthfibonacci)		{			current = previous2 + previous1;			previous1 = previous2;			previous2 = current;			counter++;		}	}	cout << "your number is " << current << endl;	return 0;}