Hello everybody I'm doing a program that finds the nth number in the fibonacci sequence. I actually already coded it. What I would like someone to do is maybe you could help me code it another way. The reason is the last assignment I turned in got a zero, because the code was similar to other students code. I don't talk with other the other students, and I do not share code with the other students.I do not know how me and other students had similar code. I only use online help that may be the reason. Hopefully this second code will not be similar to others and I won't risk the chance of getting another zero.
get the input from the user.
def main():
print("This is a program to compute the nth Fibonacci number.")
n = eval(input("What number do you want to know? :"))
a,b,c = 0,1,0
count = 1
create a list first position needs to be one.
The result needs to be 1,1,3,5,8.
not 1,2,3,5,8
Fibonacci = list([1])
while count <n:
c = a + b
a = b
b = c
# add the result into the list.
Fibonacci.append(c)
count = count + 1
print("\nFibonacci number {0}th is: {1}" .format(n, Fibonacci[n-1]))
main()