What am i doing wrong?
trying to make a code to display all numbers with a "prime"-" not prime code" https://code.sololearn.com/c13KtZRG5gfD/?ref=app
Just some syntax errors, btw the logic behind the code is not the right one to collect prime numbers, keep in mind that Sololearn will return a "Time Limit Exceeded". Protip: indent the code. Useful link: https://www.programiz.com/cpp-programming/examples/prime-number https://code.sololearn.com/cYm3ZIEnjHDO/?ref=app
A couple of errors: - one isn't really a good starting point as it divides into everything, - while loop goes for a long time until number overflows into negative numbers, - number/number is always 1 so everything is going to be called a prime, and - you will get time limit exceeded error aborting your code before it finishes executing. Start simple do ten numbers to prove you got things right. Start number at 2. Change your while to while (number <= 10). Primes can't be divided by any numbers between 2 and number/2 so you need a testing loop to check this.
yeah I noticed that, it still will spit out a bunch of numbers, also the first part in the if Will never work out I was mostly just trying to write my fist code
Try outputting 2 to 10 first
alright thanks, let's see how it works out
ohhh thank you, I see where I was wrong :)