Answer:
In Python:
def fib(nterms):
n1, n2 = 1, 1
count = 0
while count < nterms:
term = n1
nth = n1 + n2
n1 = n2
n2 = nth
count += 1
return term
Explanation:
This line defines the function
def fib(nterms):
This line initializes the first and second terms to 1
n1, n2 = 1, 1
This line initializes the Fibonacci count to 0
count = 0
The following while loops gets the number at the position of nterms
<em> while count < nterms:
</em>
<em> term = n1
</em>
<em> nth = n1 + n2
</em>
<em> n1 = n2
</em>
<em> n2 = nth
</em>
<em> count += 1
</em>
This returns the Fibonnaci term
return term
I can solve it with Java. Here it is:
areaOfSquare = stdin.nextDouble();
double sqrt = Math.sqrt(areaOfSquare);
if(Double.isNaN(sqrt)){
System.out.print("INVALID");
} else {
System.out.print(sqrt);
}
B. FILE PAGES
I answered wrong the first time, but according to an exam the answer is B. Definitely trust an exam answer!
<span>C. when listing items that have an order of priority
</span>