Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Project Euler #2
//Title of this code //'main' method must be in a class 'Rextester'. //Compiler version 1.8.0_45 import java.util.*; import java.lang.*; class Rextester { public static void main(String args[]) { int sum = 0; int count = 1; int countB = 2; while (count < 4000000) { if ((count%2==0)&&(countB%2==0)){ sum =+ count + countB; } else if (count%2==0) { sum+= count; } else if (countB%2==0) { sum+=countB; } System.out.println("SUM: "+sum); //System.out.println("count: "+count); count += countB; System.out.println("count2: "+count); countB += count; System.out.println("countB: "+countB); } System.out.println(sum); } }
run
|
edit
|
history
|
help
0
Basic LinkedList in Java
СОРТИРОВКА СЛИЯНИЕМ
3.E
Sort an array of 0's 1's 2's
bookstore (shopping,user,personal,borrowing)
Oh no
Neeraj
pattern2
Coding Challenge - 01 (Even numbers)
dfkbzhfvjahfjh