In Python: Write a function called is_prime that receives a single integer value between 1 and 50 determines whether or not the integer is a prime. To determine if a number less than 50 is prime, you only need to divide it by all prime numbers less than or equal to the square root of 50 (i.e., 2, 3, 5, and 7). If any of them are smaller than the number and evenly divide the number, then it is not prime. By definition, 1 is not prime. Your solution should use the guess-and-check pattern. Write a main() function in your file to exercise your function to show that it works correctly. Your test implementation should not rely on visual inspection to determine if the tests pass.
In Python:
Write a function called is_prime that receives a single integer value between 1 and 50 determines whether or not the integer is a prime. To determine if a number less than 50 is prime, you only need to divide it by all prime numbers less than or equal to the square root of 50 (i.e., 2, 3, 5, and 7). If any of them are smaller than the number and evenly divide the number, then it is not prime. By definition, 1 is not prime. Your solution should use the guess-and-check pattern.
Write a main() function in your file to exercise your function to show that it works correctly. Your test implementation should not rely on visual inspection to determine if the tests pass.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 2 images