Jump to content

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
https://linustechtips.com/topic/1124530-need-some-help/
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
https://linustechtips.com/topic/1124530-need-some-help/#findComment-13052863
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
https://linustechtips.com/topic/1124530-need-some-help/#findComment-13052891
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
https://linustechtips.com/topic/1124530-need-some-help/#findComment-13052894
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

×