OLD | NEW |
(Empty) | |
| 1 from recipe_engine.recipe_api import Property |
| 2 from recipe_engine import config |
| 3 import math |
| 4 |
| 5 DEPS = [ |
| 6 'recipe_engine/properties', |
| 7 ] |
| 8 |
| 9 PROPERTIES = { |
| 10 'curr_prime': Property(kind=int), |
| 11 } |
| 12 |
| 13 RETURN_SCHEMA = config.ReturnSchema( |
| 14 result=config.Single(int), |
| 15 ) |
| 16 |
| 17 def is_prime(val): |
| 18 if val % 2 == 0: |
| 19 return False |
| 20 for div in range(3, math.ceil(math.sqrt(val))): |
| 21 if val % div == 0: |
| 22 return False |
| 23 return True |
| 24 |
| 25 def RunSteps(api, curr_prime): |
| 26 curr_prime += 2 |
| 27 while not is_prime(curr_prime): |
| 28 curr_prime += 2 |
| 29 |
| 30 return RETURN_SCHEMA(result=curr_prime) |
| 31 |
| 32 def GenTests(api): |
| 33 yield ( |
| 34 api.test('basic') + |
| 35 api.properties(curr_prime=3) |
| 36 ) |
OLD | NEW |