
Patrick M. answered 04/22/22
Software Engineer Level II with 5 years Python experience
This is not an efficient algorithm, but it does the job! You can adapt it to your specific input/output needs.
Bobby J.
asked 04/16/22The JSON inputs will be positive integers.
For RSA, we need to select two huge random numbers in real-world scenarios. We can do this by picking a random number and then testing it for primality. This exercise will supply you with an array of positive and representable integers in 32 bits. For each integer, you will output a boolean value of true
if it is prime, and false
if it is not.
You're welcome to use a fancy probabilistic algorithm, such as the Miller-Rabin test (which is very commonly used in crypto libraries). Still, you should be able to use trial division... even though it might take a while to grade (2^32 is a lot of trials... at least skip even numbers after 2).
Input:
"problem 1" : |
{ |
"numbers" : [3, 4, 5, 6] |
}, |
Patrick M. answered 04/22/22
Software Engineer Level II with 5 years Python experience
This is not an efficient algorithm, but it does the job! You can adapt it to your specific input/output needs.
Get a free answer to a quick problem.
Most questions answered within 4 hours.
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.