Advertisement
Guest User

Untitled

a guest
Oct 20th, 2017
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. public class euler {
  2.     public static double doorAmt = Math.pow(10,12);
  3.     public static long doorLocation = 0;
  4.     public static long doorsOpened = 0;
  5.     public static boolean stepsDone = false;   
  6.  
  7.     public static void main(String[] args) {
  8.         for (long i = 0; i < doorAmt; i++) {
  9.             if (!stepsDone) {
  10.                 doorLocation += (Math.pow(i, 2) + Math.pow(i+1, 2));
  11.                 stepsDone = true;
  12.             } if (stepsDone) {
  13.                 doorsOpened++;
  14.                 stepsDone = false;
  15.             }
  16.         }
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement