Date: 18 July, 2023
Model: gpt-3.5-turbo
Temperature: 0.2
Passing runs: 10
Total runs: 10
Success rate: 100%
Tokens: 78
def fib(n: int):
"""Return n-th Fibonacci number.
>>> fib(10)
55
>>> fib(1)
1
>>> fib(8)
21
"""
The above is an incomplete Python code fragment. Return the complete and correct code with no additional text.
def fib(n: int):
"""Return n-th Fibonacci number.
>>> fib(10)
55
>>> fib(1)
1
>>> fib(8)
21
"""if n == 0:
return 0
if n == 1:
return 1
return fib(n - 1) + fib(n - 2)
METADATA = {}
def check(candidate):
assert candidate(10) == 55
assert candidate(1) == 1
assert candidate(8) == 21
assert candidate(11) == 89
assert candidate(12) == 144
Start time: 2023-07-18 17:19:36
Duration: 4.9s
Completion tokens: 130
Result: Pass
def fib(n: int):
"""Return n-th Fibonacci number.
>>> fib(10)
55
>>> fib(1)
1
>>> fib(8)
21
"""
if n <= 0:
return None
elif n == 1:
return 1
elif n == 2:
return 1
else:
fib_list = [1, 1]
for i in range(2, n):
fib_list.append(fib_list[i-1] + fib_list[i-2])
return fib_list[n-1]
Start time: 2023-07-18 17:19:31
Duration: 4.78s
Completion tokens: 139
Result: Pass
def fib(n: int):
"""Return n-th Fibonacci number.
>>> fib(10)
55
>>> fib(1)
1
>>> fib(8)
21
"""
if n <= 0:
return "Invalid input. n must be a positive integer."
elif n == 1:
return 1
elif n == 2:
return 1
else:
fib_list = [1, 1]
for i in range(2, n):
fib_list.append(fib_list[i-1] + fib_list[i-2])
return fib_list[n-1]
Start time: 2023-07-18 17:19:26
Duration: 5.48s
Completion tokens: 139
Result: Pass
def fib(n: int):
"""Return n-th Fibonacci number.
>>> fib(10)
55
>>> fib(1)
1
>>> fib(8)
21
"""
if n <= 0:
return "Invalid input. n must be a positive integer."
elif n == 1:
return 1
elif n == 2:
return 1
else:
fib_list = [1, 1]
for i in range(2, n):
fib_list.append(fib_list[i-1] + fib_list[i-2])
return fib_list[n-1]
Start time: 2023-07-18 17:19:21
Duration: 4.6s
Completion tokens: 138
Result: Pass
def fib(n: int):
"""Return n-th Fibonacci number.
>>> fib(10)
55
>>> fib(1)
1
>>> fib(8)
21
"""
if n <= 0:
return "Invalid input. Please enter a positive integer."
elif n == 1:
return 1
elif n == 2:
return 1
else:
fib_list = [1, 1]
for i in range(2, n):
fib_list.append(fib_list[i-1] + fib_list[i-2])
return fib_list[n-1]
Start time: 2023-07-18 17:19:16
Duration: 5.28s
Completion tokens: 139
Result: Pass
def fib(n: int):
"""Return n-th Fibonacci number.
>>> fib(10)
55
>>> fib(1)
1
>>> fib(8)
21
"""
if n <= 0:
return "Invalid input. n must be a positive integer."
elif n == 1:
return 1
elif n == 2:
return 1
else:
fib_list = [1, 1]
for i in range(2, n):
fib_list.append(fib_list[i-1] + fib_list[i-2])
return fib_list[n-1]
Start time: 2023-07-18 17:19:10
Duration: 5.35s
Completion tokens: 139
Result: Pass
def fib(n: int):
"""Return n-th Fibonacci number.
>>> fib(10)
55
>>> fib(1)
1
>>> fib(8)
21
"""
if n <= 0:
return "Invalid input. n should be a positive integer."
elif n == 1:
return 1
elif n == 2:
return 1
else:
fib_list = [1, 1]
for i in range(2, n):
fib_list.append(fib_list[i-1] + fib_list[i-2])
return fib_list[n-1]
Start time: 2023-07-18 17:19:04
Duration: 5.96s
Completion tokens: 138
Result: Pass
def fib(n: int):
"""Return n-th Fibonacci number.
>>> fib(10)
55
>>> fib(1)
1
>>> fib(8)
21
"""
if n <= 0:
return "Invalid input. Please enter a positive integer."
elif n == 1:
return 1
elif n == 2:
return 1
else:
fib_list = [1, 1]
for i in range(2, n):
fib_list.append(fib_list[i-1] + fib_list[i-2])
return fib_list[n-1]
Start time: 2023-07-18 17:18:59
Duration: 5.25s
Completion tokens: 139
Result: Pass
def fib(n: int):
"""Return n-th Fibonacci number.
>>> fib(10)
55
>>> fib(1)
1
>>> fib(8)
21
"""
if n <= 0:
return "Invalid input. n must be a positive integer."
elif n == 1:
return 1
elif n == 2:
return 1
else:
fib_list = [1, 1]
for i in range(2, n):
fib_list.append(fib_list[i-1] + fib_list[i-2])
return fib_list[n-1]
Start time: 2023-07-18 17:18:54
Duration: 5.19s
Completion tokens: 139
Result: Pass
def fib(n: int):
"""Return n-th Fibonacci number.
>>> fib(10)
55
>>> fib(1)
1
>>> fib(8)
21
"""
if n <= 0:
return "Invalid input. n must be a positive integer."
elif n == 1:
return 1
elif n == 2:
return 1
else:
fib_list = [1, 1]
for i in range(2, n):
fib_list.append(fib_list[i-1] + fib_list[i-2])
return fib_list[n-1]
Start time: 2023-07-18 17:18:48
Duration: 5.56s
Completion tokens: 132
Result: Pass
def fib(n: int):
"""Return n-th Fibonacci number.
>>> fib(10)
55
>>> fib(1)
1
>>> fib(8)
21
"""
if n <= 0:
return "Invalid input"
elif n == 1:
return 1
elif n == 2:
return 1
else:
fib_list = [1, 1]
for i in range(2, n):
fib_list.append(fib_list[i-1] + fib_list[i-2])
return fib_list[n-1]