This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sum = 0 | |
for x in range(999, 1, -1): | |
if x % 5 == 0 or x % 3 == 0: | |
print(x) | |
sum += x | |
print(sum) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def fib (n) : | |
if (n == 1 or n==2): | |
return 1 | |
return (fib(n-1) + fib(n-2)) | |
limit = 4000000 | |
x = 1 | |
sum = 0 | |
a = 0 | |
while a < limit: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def primer(n): | |
notprime = False | |
for x in range(2 , n): | |
for y in range (2, x): | |
if x%y == 0: | |
notprime = True | |
break | |
if notprime == False and n % x == 0: | |
print(str(x) + " is prime and is a factor") | |
notprime = False |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def palindrome(str): | |
return str == str[::-1] | |
for i in range(100, 999): | |
for j in range(100,999): | |
if(palindrome(str(i*j))): | |
print(i*j) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def divisible (n): | |
if(n % 7 != 0): | |
return False | |
if(n % 9 != 0): | |
return False | |
if(n % 11 != 0): | |
return False | |
if(n % 13 != 0): | |
return False | |
if(n % 16 != 0): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def sumofsquares (n): | |
sum = 0 | |
for x in range(1,n+1): | |
sum += x*x | |
return sum | |
def squareofsum(n): | |
sum = 0 | |
for x in range(1,n+1): | |
sum += x |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def primer(n): | |
notprime = False | |
primecount = 0 | |
x = 2 | |
while True: | |
for y in range (2, x): | |
if x%y == 0: | |
notprime = True | |
break | |
if notprime == False: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def mthndigits(number,m,n): | |
a = str(number) | |
return int(a[m:m+n]) | |
def digitmultiply(number): | |
stringfied = str(number) | |
product = 1 | |
for x in stringfied: | |
product *= int(x) | |
return product |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
print(5*7*9*11*13*16*17*19) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Special thanks to Ceyhan Yılmaz and cosinus | |
def nthPrime(n): | |
number = 3 | |
primemultiples = [] | |
primes = [] | |
primes.append(2) | |
prime = True | |
while (len(primes)<=n): | |
prime = True | |
if number in primemultiples: |
OlderNewer