Йордан обнови решението на 01.04.2015 23:32 (преди над 9 години)
+
+def fibonacci():
+ current = 1
+ previous = 0
+ next_fib = 1
+ yield next_fib
+ while True:
+ next_fib = current + previous
+ yield next_fib
+ previous = current
+ current = next_fib
+
+
+def primes():
+ # helper func to check prime number
+ def is_prime(n):
+ for num in range(2, n):
+ if n % num == 0:
+ return False
+ return True
+
+ number_to_check = 2
+
+ while True:
+ if is_prime(number_to_check):
+ yield number_to_check
+ number_to_check += 1
+
+
+def alphabet(code=None, letters=""):
+ APLTHABET = {
+ "lat": "abcdefghijklmnopqrstuvwxyz",
+ "bg": "абвгдежзийклмнопрстуфхцчшщъьюя"
+ }
+ if letters == "" and code != "":
+ letters = APLTHABET[code]
+
+ for letter in letters:
+ yield letter
+