java - Does my program have a runtime error or does my computer not have the power to run my program? -


So I started the Euler project and the first problem was very simple, although I could not find the answer because the program I created Is not running. It just compiles, but when I run it, it never runs Project Allar says that "problems with efficient implementation will allow a moderately operated computer to get the solution in less than a minute." Which goes to my question, am I stuck in an infinite loop or do not have the power to run my program on my computer?

The problem is: If we list all the natural numbers below 10 which are multiples of 3 or 5, then we have 3, 5, 6 and 9. The sum of these multiples is 23.

Find the sum of all the multiples of 3 or 5 below 1000.

  public class Euler1 {public static zero main (string [] args) {double X = 1; Int count = 0; Integer = 0; While (x <1000) {if ((x / 3 == (int) x)} (x / 5 == (int) x)) {count ++; X ++; Total + = X; }} System.out.println (total); }  

}

Your program is incorrect.

  while (x and lt; 1000) {if ((x / 3 == (int) x)} (x / 5 == (int) x)) {count ++; X ++; Total + = X; }}  

Keep in mind that if the situation is true then X is only increased. X starts with 1, so the position is not correct, so x never increases and remains at 1.

Also, x / 3 == (int) x and are not tested for X / 5 == (Int) x divisibility None of them is ever true unless the X is 0.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -