Hexadecimal interview

Discuss about the puzzles, but without giving the solutions please !!!

Hexadecimal interview

Postby admin » Sat Mar 26, 2011 6:58 pm

This puzzle is a variant of the typical job interview question what are the number of trailing zeros of a factorial ?

This puzzle requires you to write a program that computes the number of trailing zeros of factorial(v), when this number is represented in hexadecimal.


User avatar
admin
Site Admin
 
Posts: 333
Joined: Thu Dec 23, 2010 1:27 am

Re: Hexadecimal interview

Postby Prashant Verma » Wed Aug 31, 2011 10:48 pm

can anyone explain to me how is the op for 15 is 2 . should it not be 3 ?
and also for for 18 3 instead of 4.
pls help.
User avatar
Prashant Verma
 
Posts: 1
Joined: Sun Jul 24, 2011 6:44 pm

Re: Hexadecimal interview

Postby David Berthelot » Wed Sep 07, 2011 3:06 pm

Well, here's a little python code that shows why:

Code: Select all
Python 2.6.4 (r264:75708, Oct 26 2009, 08:23:19) [MSC v.1500 32 bit (Intel)] on
win32
Type "help", "copyright", "credits" or "license" for more information.
>>> fact = lambda x:fact(x-1)*x if x > 0 else 1
>>> print hex(fact(15))
0x13077775800L
>>> print hex(fact(18))
0x16beecca730000L
User avatar
David Berthelot
 
Posts: 43
Joined: Sun Jan 16, 2011 5:06 pm


Return to Puzzles

Who is online

Users browsing this forum: No registered users and 3 guests

cron