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 01:20
Me with this program in c++ ! computers represent color by combining sub-colors red, green, and blue (rgb). each sub-color's value can range from 0 to 255. thus (255, 0, 0) is bright red. (130, 0, 130) is a medium purple. (0, 0, 0) is black, (255, 255, 255) is white, and (40, 40, 40) is a dark gray. (130, 50, 130) is a faded purple, due to the (50, 50, 50) gray part. (in other word, equal amounts of red, green, blue yield gray).given values for red, green, and blue, remove the gray part. ex: if the input is 130 50 130, the output is: 80 0 80. thus, find the smallest value, and then subtract it from all three values, thus removing the gray.
Answers: 3
question
Computers and Technology, 24.06.2019 07:50
Write a defining table and then a program that determines if you can sleep in or not. your program should get all its input from your computer’s clock. on all weekdays (monday through friday) that are not holidays, your program should output “get up! ” on all other days (weekends and holidays), your program should output “sleep in.” the three holidays that your program must check for are january 1 (new year’s day), july 4 (u.s. independence day), and december 25 (christmas). you don’t need to include other holidays in your program because most other holidays do not occur on a fixed day each year.
Answers: 1
question
Computers and Technology, 24.06.2019 16:00
What is a dashed line showing where a worksheet will be divided between pages when it prints? a freeze pane a split box a page break a print title
Answers: 1
question
Computers and Technology, 24.06.2019 16:30
You may see the term faq on websites which stands for frequently asked questions this is an example of which type of mnemonic? a) poem b) acronym c) acrostic d) abbreviation ken has dipped many dark chocolate marshmallows (which you remember the metric system distance units in decreasing order: kilometers, hectometer, decameter, centimeter, millimeter) is an example of which type of mnemonic? a) poem b) acronym c) acrostic d) abbreviation !
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