In my code I calculate the first 30 numbers in the Fibonacci sequence (store as an array) and then take an integer as input ,factor it and store as an array. This comparison statement says the largest factor that is also a Fibonacci number. However it currently prints every number that is in both arrays. I want it to print only the largest. I tried a break; statement and it only prints the smallest...Any ideas would be great.
for( int f=length; f>0;f--) //fib array
{
for (int fact=0; fact<length; fact++)//factor array
{
if (fib[f]==factor[fact])
{cout<<"The largest factor of "<<x<<" that is a Fibonacchi Number is " <<fib[f]<<endl;}
} //end factor for loop