diff --git a/lib/newman_conway.py b/lib/newman_conway.py index 7f5341a..a887e93 100644 --- a/lib/newman_conway.py +++ b/lib/newman_conway.py @@ -1,6 +1,22 @@ def newman_conway(num): - """ Returns a list of the Newman Conway numbers for the given value. - Time Complexity: ? - Space Complexity: ? - """ - pass + + if num <= 0: + raise ValueError + elif num == 1: + return '1' + + + f = [0, 1, 1] + + print(f[1], end='') + print(f[2], end='') + for i in range(3, num + 1): + f.append(f[f[i-1]] + f[i-f[i -1]]) + print(f[i], end='') + + + sequence = [str(x) for x in (f[1:])] + + return ' '.join(sequence) + +