100 Followers Crossing Confusion !

How many ones are there in the decimal representation of 100 ! 100!


When I saw the no. of followers, it was 100. I overwhelmed and I decided to post my 100 followers tribute problem.

19 15 13 17 24

This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try refreshing the page, (b) enabling javascript if it is disabled on your browser and, finally, (c) loading the non-javascript version of this page . We're sorry about the hassle.

3 solutions

Brock Brown
Feb 18, 2015

Python:

1
2
from math import factorial
print "Answer:", str(factorial(100)).count('1')

Whee

What do you mean by "from math import factorial" and why is 'math' underlined,is it a link?

Adarsh Kumar - 6 years, 1 month ago

Log in to reply

"factorial" is a function in Python, and from the line "from math import factorial" he meant to load the function factorial from the package "math" into the interpreter.

Venkata Karthik Bandaru - 6 years, 1 month ago

Log in to reply

ah!thanx a lot bud!did u go for coaching in CS??If yes,where?

Adarsh Kumar - 6 years, 1 month ago

Log in to reply

@Adarsh Kumar No coaching bro, self taught !

Venkata Karthik Bandaru - 6 years, 1 month ago

Log in to reply

@Venkata Karthik Bandaru sites or books?

Adarsh Kumar - 6 years, 1 month ago
Ivan Koswara
Feb 17, 2015

Python one-liner:

1
2
3
import math
print(sum((1 if i=="1" else 0) for i in str(math.factorial(100))))
# prints 15

Mathematica Code :-

DigitCount[ 100 ! , 10 , 1 ] 100!, 10, 1 ]

Note :-

DigitCount[a,b,c] gives the number of digits c in the decimal representation of a in base b.

0 pending reports

×

Problem Loading...

Note Loading...

Set Loading...