fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.math.*;
  7.  
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. BigInteger []arr = new BigInteger[1000];
  14. arr[0]=BigInteger.ZERO;arr[1]=BigInteger.ONE;
  15. for(int i=2;i<1000;i++){
  16. arr[i] = arr[i-1].add(arr[i-2]);
  17. }
  18. String s;
  19. while((s=k.readLine())!=null){
  20. out.println(arr[Integer.parseInt(s)]);
  21. }
  22. out.close();
  23. k.close();
  24. // your code goes here
  25. }
  26. }
Success #stdin #stdout 0.07s 380224KB
stdin
1
2
3
4
5
stdout
1
1
2
3
5