Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 3

def isPrime(n):

if (n < 2):
return False
for factor in range(2, n):
if (n % factor == 0):
return False
return True

def fasterIsPrime(n):
if (n < 2):
return False
if (n == 2):
return True
if (n % 2 == 0):
return False
maxFactor = round(n ** 0.5)
for factor in range(3,
maxFactor+1, 2):
if (n % factor == 0):
return False
return True
def sumtoN(n):
total = 0
for i in range(1,n+1):
total += i
return total

def nthPrime(n):
found = 0
guess = 0
while (found <= n):
print(guess)
guess += 1
if (isPrime(guess)):
found += 1
return guess

# string
print('hello world')
print("hello world")
print('''hello world''')
print("""hello world""")

print('"')
print("'")

print('''
Hello, my name is Milson
Nice to meet you

''')

You might also like