Томислав обнови решението на 15.03.2012 17:46 (преди почти 13 години)
+def prepare_meal(number):
+ meal = []
+ degree = 1
+ include_eggs = False
+ while (3 ** degree) < number + 1:
+ if (number % (3 ** degree)) == 0:
+ if (include_eggs == True):
+ meal.insert(0, 'spam')
+ else:
+ meal.append('spam')
+ if (number % (5 ** degree)) == 0 and meal.count('spam') > 0 and meal.count('and eggs') == 0:
+ meal.append('and eggs')
+ include_eggs = True
+ else:
+ if((number % (5 ** degree)) == 0):
+ meal.append('eggs')
+ include_eggs = True
+ degree = 1 + degree
+ return ' '.join(str(n) for n in meal)
+
+print(prepare_meal(45))