#Trying to find if the number is prime or not

1 messages · Page 1 of 1 (latest)

rigid mesaBOT
#

<@&987246399047479336> please have a look, thanks.

wary cedar
#

alr bro

#

don’t ping em

cedar crown
#

its a bot, and as adviced in the other thread, fix your variables,they are not correct

limpid robin
#

You haven't asked your question

quaint lance
quaint lance
#

It just gives me the output, not a prime number.

#

Even if I put in 19, or 17.

limpid robin
cedar crown
#

do not spoonfeed plz

pine vector
#

like whats the problem

#

oh ok

quaint lance
cedar crown
#

code is correct

quaint lance
cedar crown
#

maybe its doing what the definition of a prime is

quaint lance
limpid robin
#

that's impossible

#

what does it print ?

cedar crown
#

it is, he's using if(VALUED%checkNumber == 0) {

limpid robin
quaint lance
limpid robin
#

so it says Number is not Prime

quaint lance
#

Yes.

limpid robin
#

look at your loop

#

int checkNumber = 1

#

so 19 % 1 == 0

quaint lance
#

I had to put 2 there.

#

Got it.

limpid robin
#

also

#

even with that, it's still not correct

#

but try to run your code

quaint lance
#

It's not giving me any problems so far.

cedar crown
#

try an even number

quaint lance
#

Works fine.

#

193 is prime, and 192 isn't. It's running well.

limpid robin
quaint lance
#

Shows it's a prime number.

#

Which it isn't.

limpid robin
#

yes

#

read your code again

#

maybe use a debugger

#

but try to understand how your method works

quaint lance
#

For the time being I'll use this, I'll fix other things later.

#

Since it's for a project.

limpid robin
#

no

#

this method simply doesn't work

#

the loop does absolutelly nothing

#

fix it

#

it will fail against any numbers that are not prime but are odd