Created
March 14, 2019 12:49
-
-
Save mcihad/d914fdea759177dd4f2b1c79d040ffe9 to your computer and use it in GitHub Desktop.
Çeşitli
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
import math | |
#verilen aralığa kadar asal sayıları bul ve liste olarak geri döndür find_primes(100) | |
find_primes = lambda j: list(filter(lambda x: not any([i for i in range(2, int(round(math.sqrt(x))) + 1) if x % i == 0]), list(range(2, j + 1)))) | |
#fibonacci jeneratörü | |
def fibonacci(to): | |
a, b = 1, 1 | |
count = 1 | |
while (count < to): | |
count += 1 | |
a, b = b, a + b | |
yield a | |
#daha anlaşılır asal sayı kontrolü | |
def is_prime(number): | |
to = int(round(math.sqrt(number))) | |
for i in range(2, to + 1): | |
if number % i == 0: | |
return False | |
return True |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment