Стилиян обнови решението на 01.04.2015 01:00 (преди над 9 години)
+def fibonacci():
+ last_number = 0
+ number = 1
+ while True:
+ yield number
+ last_number, number = number, last_number + number
+
+
+def primes():
+ number = 2
+ while True:
+ if is_prime(number):
+ yield number
+ number += 1
+
+
+def is_prime(n):
+ if n <= 3:
+ return n >= 2
+ if n % 2 == 0 or n % 3 == 0:
+ return False
+ for i in range(5, int(n ** 0.5) + 1, 6):
+ if n % i == 0 or n % (i + 2) == 0:
+ return False
+ return True
+
+
+def alphabet(**kwargs):
+ if 'letters' in kwargs:
+ for letter in kwargs['letters']:
+ yield letter
+ elif kwargs['code'] == 'lat':
+ for latin_letter in range(97, 123):
+ yield chr(latin_letter)
+ else:
+ for bg_letter in range(1072, 1103):
+ yield che(bg_letter)