Hi there, the code below is suppose to output all the prime numbers between the values of startNum and endNum variables. but its not working correctly instead it display all the numbers between startnum and endNumber including non-prime numbers. please help.
the code doen't work, if i test the numbers between 9 and 30 it starts at 17 by displaying it ten time and then it says 18 is prime two times and two more times it says 18 not prime and so on...
> if i test the numbers between 9 and 30 it starts at 17
scroll.
> the code doen't work,
your prime definition is wrong
if(isPrime == true)¿why are you comparing a boolean value against `true'? it will give you a boolean value (that you think you should compare against `true')
((isPrime==true) == true) == true ...
The code works just fine. It's the algorithm that doesn't work.
The code just does what it was told to do. It was my hope that by looking at the output of the code with the changes I made, you would realize that the algorithm was wrong.
Get out a pen and pencil and work out how you would do this by hand, then convert that algorithm into code.