+ 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.

4th Nov 2020, 3:01 PM
Muhammad Abdullah
Muhammad Abdullah - avatar
3 odpowiedzi
+ 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 👍
4th Nov 2020, 3:11 PM
Ipang
4th Nov 2020, 3:11 PM
Benjamin Jürgens
Benjamin Jürgens - avatar
+ 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.
4th Nov 2020, 3:08 PM
Jayakrishna 🇮🇳