Skip to content

Instantly share code, notes, and snippets.

View BedirYilmaz's full-sized avatar
🌍

Bedir Yılmaz BedirYilmaz

🌍
View GitHub Profile
@BedirYilmaz
BedirYilmaz / Soru5.py
Last active October 18, 2016 09:51
Find the smallest positive number that is evenly divisible by all of the numbers from 1 to 20
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):
@BedirYilmaz
BedirYilmaz / Soru4.py
Created October 12, 2016 07:44
Finding the largest palindrome made from the product of two 3-digit numbers.
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)
@BedirYilmaz
BedirYilmaz / Soru3.py
Created October 11, 2016 10:45
Listing the prime factors of given number
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
@BedirYilmaz
BedirYilmaz / Soru2.py
Last active October 19, 2016 07:38
Sum of the even fibonacci numbers that are smaller than 4000000
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:
@BedirYilmaz
BedirYilmaz / Soru1.py
Last active October 11, 2016 08:02
Sum of all numbers that are smaller than 999 and can be divided by 5 or 3
sum = 0
for x in range(999, 1, -1):
if x % 5 == 0 or x % 3 == 0:
print(x)
sum += x
print(sum)