+ 1
In have a question, i kno the programming but dont know how to do the math.
I know what is a prime number but how to do the math in a c++ program 1. Program to take a number and tell if it is a prime or not. 2. Program that takes 2 numbers and displays all prime between them. 3. Program that takes a number and outputs the largest prime number, smaller than the number entered. Just tell me the math. I will write the program my self.
3 Antworten
+ 3
It's great to know you are not one of those who ask others to write code for them. For this good intent, I support you.
But if I may suggest, you have a better option. You can search Code Playground for prime number related codes, and you can learn the various techniques people employ to do primality check 👍
+ 2
https://en.wikipedia.org/wiki/Prime_number#Computational_methods
You should find what you need there
+ 1
Learn about arithmetic operators. And It's work..
Prime number have only 1 and itself factors. So a number is factor or not of another number is : can be checked by num1%num2 if 0 then num2 is factor of num1 else not.