Answer the question
In order to leave comments, you need to log in
How to define a prime number?
The input is the number X. For example: 1312312312412412512951028509102951 (it is certainly large), it is necessary to determine 100% that this number is prime or not.
The bottom line is that the number is obviously large, and it does not fit the already prepared data type (unsigned long long). Therefore, it is transmitted as a char*, that is, it is transmitted as a line.
So I don’t understand, either to translate this line into a number, but this is meaningless, since there is nowhere to store the number (data type). Or compare with ready-made numbers (translated into a line).
But here is also a problem, if we take the algorithm head-on: p = 2^n - 1, где p - простое число
Then there can be infinitely many calculations, because everything here will depend on the input parameter.
Tell me, please, how can I solve the problem?
Answer the question
In order to leave comments, you need to log in
You can resort to large numbers, and work with them already.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question