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, 22.06.2019 18:30
Which of the following is an example of intellectual properly! oa. new version of a novelb. journal of ideasc. pages of a bookood. lines of a poem
Answers: 2
question
Computers and Technology, 23.06.2019 19:30
Anul 2017 tocmai s-a încheiat, suntem trişti deoarece era număr prim, însă avem şi o veste bună, anul 2018 este produs de două numere prime, 2 şi 1009. dorel, un adevărat colecţionar de numere prime, şi-a pus întrebarea: “câte numere dintr-un interval [a,b] se pot scrie ca produs de două numere prime? “.
Answers: 1
question
Computers and Technology, 23.06.2019 22:40
22. sata3 allows for data transfer rates of 600 mb/s. explain why you would likely not be able to copy data from one hard drive to another at anywhere close to this speed. also, what could be upgraded on the computer to achieve transfer speeds closer to 600 mb/s
Answers: 1
question
Computers and Technology, 24.06.2019 12:50
When is it most apprpriate for a development team to change the definition of done
Answers: 1
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
Mathematics, 26.02.2021 04:20
question
Social Studies, 26.02.2021 04:20
question
Mathematics, 26.02.2021 04:20
question
Mathematics, 26.02.2021 04:20
question
Mathematics, 26.02.2021 04:20
question
Computers and Technology, 26.02.2021 04:20
question
English, 26.02.2021 04:20
question
Business, 26.02.2021 04:20
Questions on the website: 13722363