So last week I travelled to Ann Arbor, Michigan to recruit for my company. I’ve pounded the table for a while about needing to broaden our college presence beyond the first two coasts, and so I got to put my time where my mouth was. I took this particular one because I grew up in Ann Arbor, and my parents live there.
First, though a rant about the university/private-sector interface. The career office at Michigan emailed us to tell us what the interview rooms are like. I emailed back to ask about whiteboards, wifi, etc. They replied saying “yes, we have whiteboards, but you have to bring your own markers and erasers. We’re not funded for that.” I was incredulous (talk about coals-to-Newscastle!), but I packed up our own personal whiteboard eraser into my checked-in luggage. (Don’t ask why we have a whiteboard in our dining room, OK?) I envision some underfunded university bureacrat scouring line items for _anything_ that hiring companies could be made to pay for instead. (And pay they do. Michigan charges a sum I will not disclose for the privilege of a campus recruiting visit — I much prefer the honesty of this to another public university which will remain nameless, who asks companies if they’d like to “collaborate” on faculty research, and then bars them from on-campus recruiting if they don’t figure out the game and cough up… but I digress.)
Tuesday: I know why airlines like to have you on the plane all ready to go when there are weather delays. But man, do I hate waiting on the tarmac. An hour of delay in SJC, then an hour in the plane before takeoff, then more delay in O’Hare, then two more hours on the tarmac waiting for the go-ahead. I finally make it to my Ann Arbor hotel at 2am.
Michigan in November … my colleague A. has cause to complain (having grown up in NW India), but I was _born_ there, and was once a hardy Northlander. Hardy no more – soft, weak, and whiny instead. Anyone complaining about a thirty-degree day in November deserves to be told “Well, enjoy these nice days, because _winter’s_ coming”. But there’s no substitute for a long slow autumn of getting used to it – step off the plane from somewhere warmer and you naturally think the residents are insane for living there.
Wednesday: Infosession at Michigan, and it is one tough room. Not tough like hostile, but just 40 or 50 unresponsive engineering students staring at us blankly, spread out over a huge classroom. The HR people go first, riffing on Y! in general, then my partner A. and I talk about web search. We have silly trivia questions and swag giveaways, which work a bit in breaking the ice. A’s and my questions are aggressively geeky (how many trailing zeroes in 100 factorial? – someone gets it about two minutes in). Finally the crowd loosens up, and we have good conversation about the search competition, the Valley, etc.
Then in the evening, a victory for the Treo + Yahoo! Local! A. and our two HR friends are looking for somewhere to eat, having had no time to hit the hotel and change out of our Y! T-shirts. I know the town, but from so long ago that all the restaurants are different. So we hit a random bar, and I ask Y! Local for a French restaurant nearby. Score! A good time had by all.
Thursday: Due to scheduling weirdness, this is an off day (i.e. work from the hotel). Also, coincidentally my Dad’s birthday. So I bring my good friend and colleague A. over to my parents’ for dinner. Now, you know how weird it can be when people you know from different parts of your life meet? You want them to like each other, but how sometimes it just doesn’t work out? Well …. it wasn’t like that at all! Everyone got on famously.
Friday: A. and I haven’t beaten the jet lag yet — still sleeping until 9PST/12EST, and this is the day that we pay for it. First interview at 8:30 AM (5:30 PST). My first one is 25 minutes late, and walks in saying “Sorry, man, 8:30 comes really early y’know?”. Tell me about it. But the asymmetry does help — I’m sorry, but interviewing 8 people in succession is just easier than being interviewed by 8 people… All in all a good crew of smart young people – A. opines that the quality is better than previous day-long visits to Stanford and Berkeley.
(defun f (x) (if (= x 1) x (* x (f (1- x)))))
(let ((str (princ-to-string (f 100)))) (1- (- (length str) (position-if-not (lambda (ch) (char= ch #\0)) str :from-end t))))
Worked almost the first time. Easier than actually *thinking*. On the other hand, the first time I saw fact(100), I remember wondering why where all those zeros came from. Appropriately for this post, the test answer is ‘coldly.’
So what was the answer? 🙂 And what’s the _explanation_? (Though I’ll admit that’s the way I like to do math too. (The test answer is “return”.))
Here’s the general function that gives you the number of zeros ending fact(n):
(defun nz (x)
(loop for i from 1
while (<= (expt 5 i) x)
sum (floor x (expt 5 i))))
In other words, how many 5s, 25s, 125s, … appear in the factorial products. These ‘pair up’ (as it were) with the 2s, 4s, 8s. … to produce the zero ending numbers (eg 2*5, 12*15, …, 4*25).
nz(100) = 24
It is interesting to do it the ‘hard’ way (as in my previous comment) and the ‘easy’ way (as in this comment). Calculating nz(5^6) takes about 8 seconds the hard way (for calulating the 58,746 digit f(5^6), and essentially no time for the easy way.