subject
Computers and Technology, 07.06.2021 01:00 pmdm95

Import Math Def Isprime X N 2 N 3 Return True N 2 N 2 0 Return False N 9 Return True N 3 0 Q36682051 . . . import mathdef is_prime(x):if n == 2 or n == 3:return Trueif n < 2 or n % 2 == 0:return Falseif n < 9:return Trueif n % 3 == 0:return Falser = int(n**0.5)f = 5while f <= r:print ('t',f)if n % f == 0:return Falseif n % (f + 2) == 0:return Falsef +=6return True n = int(input('Enter an integer:n'))print (is_prime(n))
I got a few questions about this code. What's the use for theline of code that says if n < 9 return True?
Lastly, I'm not sure what's going on in this part of the code. The part where n has a power of 0.5 and f = 5 are more confusing. If anyone could help, I'd appreciate it. Thank you!
r = int(n**0.5)f = 5while f <= r:print ('t',f)if n % f == 0:return Falseif n % (f + 2) == 0:return Falsef +=6return True

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 20:10
Leo is a recruitment executive for a large company. he has identified new labor resource requirements in both the marketing and production departments. what should be his first step in recruiting candidates for the positions? a. conduct background checks of candidates b. make job offers c. arrange interviews d. conduct reference checks e. place job ads on job sites
Answers: 1
question
Computers and Technology, 24.06.2019 17:30
Click on the tab on the ribbon to open the backstage view. file view insert review
Answers: 1
question
Computers and Technology, 24.06.2019 17:40
The value of sin(x) (in radians) can be approximated by the alternating infinite series create a function (prob3_2) that takes inputs of a scalar angle measure (in radians) and the number of approximation terms, n, and estimates sin(x). do not use the sin function in your solution. you may use the factorial function. though this can be done without a loop (more efficiently), your program must use (at least) one. you may find the mod() function useful in solving the problem.
Answers: 1
question
Computers and Technology, 24.06.2019 23:50
What is your fav video game currently: a) roblox b) fortnite c) apex legends d) pubg
Answers: 2
You know the right answer?
Import Math Def Isprime X N 2 N 3 Return True N 2 N 2 0 Return False N 9 Return True N 3 0 Q36682051...
Questions
question
Arts, 02.05.2021 01:40
question
Biology, 02.05.2021 01:40
question
English, 02.05.2021 01:40
Questions on the website: 13722363