Question
Method 1) We would like to determine if num is a prime number. If num == 2, then num is prime. Otherwise, if num is
Method 1) We would like to determine if num is a prime number. If num == 2, then num is prime. Otherwise, if num is divisible by any number between 2 and (num-1) then, num must NOT be prime. It is advisable to setup a loop that iterates from 2 to (num-1) inclusive to determine if any of those numbers evenly divides num. If any of them divides num, num cannot possibly be prime, so the function should return False; otherwise, if none of them divides, the function should return True
Method 2) We would like to determine if num is a prime number. Let us count all numbers from 1 to num that evenly divides num. If that count is exactly 2, then num must be a prime number. It is recommended to setup a loop that iterates from 1 to num inclusive to determine how many of those numbers evenly divides num. If that count is 2, the function should return True; otherwise, it should return False. Please use one of these approaches to define your is_prime() function. Here are the first few prime numbers below 100: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97
To test if your function is working, your function should return True for the values above.
Once you have the function properly working, design a program that prints out the first prime number that is larger than your unique 5 digit number.
Your main program should call is_prime(). Please do not use any built-in math functions to determine primes.
Your program should output a single numeric result.
For this project, you will define a function as follows: def is_prime(num): \# modify function to return True only if num is a prime number \# A prime number is any positive integer greater than 1 that is only divisible by two numbers: \# 1 and num. \# By definition 2 is a prime number; and it is the ONLY even prime number. \# this is a dummy implementation -_ for now, this function returns True. return True This function can be designed in several ways. Here are two methodsStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started