0% found this document useful (0 votes)
10 views1 page

New Sandbox Program

Uploaded by

mikeperez2512
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views1 page

New Sandbox Program

Uploaded by

mikeperez2512
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

def Fibonacci(num):

fib_series = []
a, b = 0, 1
for _ in range(num):
fib_series.append(a)
a, b = b, a + b
return fib_series

def factors(n):
factor_list = []
for i in range(1, n + 1):
if n % i == 0:
factor_list.append(i)
return factor_list, len(factor_list)

if __name__ == "__main__":
while True:
try:
user_input = int(input("Enter a number: "))
assert user_input > 0
break # Valid input; exit the loop
except ValueError:
print("Please enter a valid number.")
except AssertionError:
print("Please enter a number greater than 0.")

fib_result = Fibonacci(user_input)
factors_result, total_factors = factors(user_input)

print("Fibonacci Series:", fib_result)


print("Factors of", user_input, ":", factors_result)
print("Total number of factors:", total_factors)

You might also like