title: Finding the largest Odd Fibonacci number in the given ranges of values
body: <p>Ex: n1=100, n2=250, out=233.</p>
  
  <p>Here I have to find the largest odd fibonacci number in the given set of ranges. If an odd fibonacci number doesn't exist then it should return 0. I am getting output as 50 times 0's and then 10 times 233. Where is my mistake and how can I get the desired output?</p>
  
  <pre><code>public class Fibo {
      public static void main(String[] args) {
          try {
              int n1 = 100;
              int n2 = 250;
              int res = 0;
  
              if (n1 % 2 == 0) {
                  n1 += 1;
  
                  for (int i = n1; i &lt; n2; i += 2) {
                      if (isPerfectSquare(5 * i * i + 4) || isPerfectSquare(5 * i * i - 4))
                          res = i;
                      System.out.println(res);
                  }
              }
          } catch(Exception ignored) {
              System.out.println("0");
          }
      }
  
      public static boolean isPerfectSquare(int num) {
          double sqrt = Math.sqrt(num);
          int x = (int)sqrt;
          return Math.pow(sqrt, 2) == Math.pow(x, 2);
      }
  }
  </code></pre>