Untitled

mail@pastecode.io avatar
unknown
plain_text
5 months ago
447 B
5
Indexable
#include <iostream>
using namespace std;

int main(){
	int fib;
	int temp;
	int num1 = 0, num2= 1;
	int requiredLoop=1;
	
	cout<<"Enter Number: ";
	cin>>fib;
	
	cout<<num1<<endl;
	
	while (fib > num1){
		temp = num1;
		num1 = num2;
		num2 = temp + num2;
	
	if (!(fib > num1)&&!(fib == num1)){
		requiredLoop = 0;
		break;
	}
	cout<<num1<<endl;
	requiredLoop++;
	}
	cout<<"Required Loop: "<<requiredLoop;
	
	return 0;
}
Leave a Comment