Advertisement
Vengadora

2-2014-BLento

Nov 23rd, 2014
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.53 KB | None | 0 0
  1. import java.util.*;
  2.  
  3. public class BLento {
  4.  
  5.   static boolean esFibo(int numero) {
  6.     int a=0, b=1, f=0;
  7.    
  8.     while (f < numero) {
  9.       a = b;
  10.       b = f;
  11.       f = a+b;
  12.     }
  13.  
  14.     return f == numero;
  15.   }
  16.  
  17.   public static void main(String[] args) {
  18.     Scanner cin = new Scanner(System.in);
  19.     int n = cin.nextInt();
  20.  
  21.     while ( (n--) > 0) {
  22.       int a = cin.nextInt();
  23.  
  24.       if (esFibo(a)) {
  25.     System.out.print(a + " ");
  26.       }
  27.  
  28.       System.out.print(a + " ");
  29.  
  30.     }
  31.  
  32.     System.out.println();
  33.  
  34.   }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement