//
// CS 202 demonstration program 06
// Written by Dave Williams for 9/23/03 class
//
// Program to determine how many square root operations must be performed
// before the remaining root of an input value is equal or less than 2.
//
int Roots(float, int);
#include <iostream.h>
#include <stdlib.h>
#include <math.h>
int main()
{
long int a;
cout << "\n\nProgram to determine number of square root operations necessary"
<< "\nto reach a root <= 2.";
do
{
cout << "\n\n\n\nInput original value (0 to quit) : ";
cin >> a;
if (a == 0)
exit(0);
else
cout << endl << endl << Roots(a, 0) << " square root operations reduce"
<< " the value of the remaining root to 2. or less.";
} while(1);
return 0;
}
int Roots(float n, int count)
{
if (n <= 2.)
return count;
else
{
n = sqrt(n);
count++;
}
Roots(n, count); // call recursively
}
// 
// 
//