diff options
Diffstat (limited to 'challenge-254/packy-anderson/python/ch-1.py')
| -rwxr-xr-x | challenge-254/packy-anderson/python/ch-1.py | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/challenge-254/packy-anderson/python/ch-1.py b/challenge-254/packy-anderson/python/ch-1.py new file mode 100755 index 0000000000..8844e67441 --- /dev/null +++ b/challenge-254/packy-anderson/python/ch-1.py @@ -0,0 +1,21 @@ +#!/usr/bin/env python + +def isAPowerOfThree(n, pow = 0): + if n == pow ** 3: + return 'true' + elif n < pow ** 3: + return 'false' + return isAPowerOfThree(n, pow + 1) + +def solution(n): + print(f'Input: $n = {n}') + print(f'Output: {isAPowerOfThree(n)}') + +print('Example 1:') +solution(27) + +print('\nExample 2:') +solution(0) + +print('\nExample 3:') +solution(6)
\ No newline at end of file |
