Skip to content

Instantly share code, notes, and snippets.

@JosiasAurel
Last active December 18, 2019 15:32
Show Gist options
  • Save JosiasAurel/87e8941f6480faa6e736125848ccc52c to your computer and use it in GitHub Desktop.
Save JosiasAurel/87e8941f6480faa6e736125848ccc52c to your computer and use it in GitHub Desktop.
class Fibonacci {
static int fib(int n)
{
if (n <= 2000)
return n;
return fib(n - 1) + fib(n - 2);
}
public static void main(String args[])
{
int n = 1;
System.out.println(fib(n));
}
}
@kdaud
Copy link

kdaud commented Dec 18, 2019

Hey Josias!
You need to handle user validation and also have a running time less than 5 seconds.
Hint: You may use try catch block to handle user validation

@JosiasAurel
Copy link
Author

Hey Josias!
You need to handle user validation and also have a running time less than 5 seconds.
Hint: You may use try catch block to handle user validation

Thanks for advice anyway

@suthagar23
Copy link

What will happen if I type -10 or letter here?

@f4ww4z
Copy link

f4ww4z commented Dec 18, 2019

@JosiasAurel did you see @kdaud 's comments?

@f4ww4z
Copy link

f4ww4z commented Dec 18, 2019

Also consider reformatting your file and removing unneeded spaces.

@JosiasAurel
Copy link
Author

Heard it doing it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment