Jump to content

Need some help

Mr.wut

for homework at school i need to make program which will calculate and decide if number set by user is prime number.

i thought about doing it with an it sentence but it wolud have to go something like this: 

if (number%everything betwen number and 1==0) {

cout << "number isn't prime"

}else {

number is prime

}

and my actual question is if there exist a command that can automaticaly devides the number with evrey number betwen? 

i need to do it in c++

 

pls help.

tnx

Link to comment
Share on other sites

Link to post
Share on other sites

Do you want us to do your homework or help you understand how to do it?

A PC Enthusiast since 2011
AMD Ryzen 7 5700X@4.65GHz | GIGABYTE GTX 1660 GAMING OC @ Core 2085MHz Memory 5000MHz
Cinebench R23: 15669cb | Unigine Superposition 1080p Extreme: 3566
Link to comment
Share on other sites

Link to post
Share on other sites

36 minutes ago, Mr.wut said:

for homework at school i need to make program which will calculate and decide if number set by user is prime number.

i need to do it in c++

 

pls help.

tnx

We won't do your homework for you but if you have a specific question ask away. Remember to quote us so we get a notification.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

23 minutes ago, Sauron said:

We won't do your homework for you but if you have a specific question ask away. Remember to quote us so we get a notification.

i thought about doing it with an it sentence but it wolud have to go something like this: 

if (number%everything betwen number and 1==0) {

cout << "number isn't prime"

}else {

number is prime

}

and my actual question is if there exist a command that can automaticaly devides the number with evrey number betwen? 

 

Link to comment
Share on other sites

Link to post
Share on other sites

Just now, Mr.wut said:

and my actual question is if there exist a command that can automaticaly devides the number with evrey number betwen? 

No, but you could use a for loop. Programming isn't just about finding premade functions that do exactly what you need.

Don't ask to ask, just ask... please 🤨

sudo chmod -R 000 /*

Link to comment
Share on other sites

Link to post
Share on other sites

23 minutes ago, Sauron said:

No, but you could use a for loop. Programming isn't just about finding premade functions that do exactly what you need.

OK tnx

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×