- 1

What is wrong with this code... It's meant to output the result of a factorial and the number of occurrence of each digit...

n=int(input("enter number:")) d={1:1} def factorial (n): if n==0: result= (1,d.items()) return (result ) elif n==1: result =(1,d.items()) else: ans=n*factorial (n-1) d=dict() for a,b in (c,ans.count[c]):for c in set (ans): d[a]=b result =(ans,d.items()) return (result)

17th Jun 2017, 1:05 PM
Obumneme Anichebe
Obumneme Anichebe - avatar
1 Respuesta
- 1
Try this: def factorial(): ... number = int(input("Enter a number")) ... results = 1 ... while(number > 0): ... results *= number ... number -= 1 ... return (results) print(factorial())
17th Jun 2017, 9:19 PM
Mat
Mat - avatar