Калоян обнови решението на 03.04.2015 13:07 (преди над 9 години)
+CONVERT_TO_ALPHABET = {'lat': "abcdefghijklmnopqrstuvwxyz",
+ 'bg': 'абвгдежзийклмнопрстуфхцчшщъьюя'}
+
+
+def fibonacci(*opt):
+ older = 0
+ old = 1
+ curr = 1
+ if opt:
+ p = 1
+ while p <= opt[0]:
+ yield curr
+ curr = old + older
+ older = old
+ old = curr
+ p += 1
+ else:
+ while True:
+ yield curr
+ curr = old + older
+ older = old
+ old = curr
+
+
+def is_prime(number):
+ for i in range(2, number // 2 + 1):
+ if number % i == 0:
+ return False
+ return True
+
+
+def primes(*opt):
+ curr = 2
+ if opt:
+ p = 1
+ while p <= opt[0]:
+ yield curr
+ curr += 1
+ while not is_prime(curr):
+ curr += 1
+ p += 1
+ else:
+ while True:
+ yield curr
+ curr += 1
+ while not is_prime(curr):
+ curr += 1
+
+
+def alphabet(code='', letters=''):
+ if letters != '':
+ curr_letters = letters
+ else:
+ curr_letters = CONVERT_TO_ALPHABET[code]
+ return(let for let in curr_letters)