All pastes #403174 Raw Edit

Something

public text v1 · immutable
·published 2007-03-20 05:42 UTC
rendered paste body
//this program will find the next sequence in the Fibonnaci.  The sequence starts after the initial seed numbers.

#include <iostream>
 
using namespace std;
 
int main ()
{
    char ch;
    int num1;
    int num2;
	int temp;
	int l;
	l=0;

	cout << "Please enter two seed numbers: \n";
		 cin >> num1 >> num2;

		 if (num2 >= num1)
		 {
			 cout << "Please enter the sequence position you want to find \n";
			 cin >> l;
			 l++;
			 if (l==1)
				 cout << "Sequence # is:  " << num2;
			 else if (l==2)
				 cout << "Sequence # is:  " << num1;
			 else if (l>2)
			 {
				 for(int k=3;k<l;k++)
				 {  temp = num1 + num2;   
				 num1 = num2;  
				 num2 = temp; 
				 }
				 cout << "That number in the Fibonnaci sequence is:  " << temp << endl; 
			 }
			 else
			 {
			 cout << "Your are asking for an invalid sequence.";
			 }
		 }
		 else
			 cout << "Your second number must be greater than or equal to your first number.";
         
    cin >> ch;
    return 0;
}