You are viewing a single comment's thread. Return to all comments →
public static void main(String[] args) { Scanner in = new Scanner(System.in); int t = in.nextInt(); for(int a0 = 0; a0 < t; a0++){ long n = in.nextLong(); ArrayList<Long> arrL = new ArrayList<>(); long before = 0; long help = 0; for (long i = 1; i <= n;) { if(i % 2 == 0) { arrL.add(i); } help = i; i += before; before = help; } System.out.println(arrL.stream().mapToLong(a -> a).sum()); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Project Euler #2: Even Fibonacci numbers
You are viewing a single comment's thread. Return to all comments →