0

Hi mates :)

how are you? I hope everything is all-right.. ;)

I have a small question, it is my HW to be honest

here is the question:

"Write a method that calculates the following equation:

f(x) =

1 if x = 0,1

√ f(x-1) + √ f(x-2) if x > 1

Undefined if x < 0

using Iterative statement"

Here is my attempt:

```
import java.util.*;
public class Function
{
public void calculate()
{
Scanner scan = new Scanner( System.in );
int x, x1 = 0;
while(true)
{
System.out.println("Enter an integer (or \"00\" to exit) ");
x = scan.nextInt();
if( x == 00 )
break;
else
if( x == 0 || x == 1)
{
System.out.println("f(x) = 1");
}
else
if( x < 0 )
{
System.out.println("f(x) is undefined.");
}
else
if( x > 1 )
{
x1 = x;
}
}
}
}
```

see, in the line where ( x > 1 ) I've stopped :\ didn't know what to do!!

Any hints on how to do it?

Thanks :)