Re: Trailing zeros of 100!

2016-01-03 Thread Tony van der Hoff
On 02/01/16 17:56, Robin Koch wrote: > Am 02.01.2016 um 17:09 schrieb Tony van der Hoff: >> On 02/01/16 16:57, Robin Koch wrote: >>> sum([int(0.2**k*n) for k in range(1, int(log(n, 5))+1)]) >> >> But did you actually test it? > > Yes, should work for n >= 1. > > Why do you ask? > >From your orig

Re: Trailing zeros of 100!

2016-01-02 Thread srinivas devaki
let's put an end to this. from math import log # simple one to understand. complexity: O(n*log(n)) def countzeros_va(n): count = 0 for x in xrange(1, n + 1): while x % 5 == 0: count += 1 x //= 5 return count # better approach. complexity: O(log(n)) def

Re: Trailing zeros of 100!

2016-01-02 Thread Ben Finney
Robin Koch writes: > Am 02.01.2016 um 22:57 schrieb Chris Angelico: > >>> But did you actually test it? > >> > >> Yes, should work for n >= 1. By “test it”, Chris of course means test it *by implementing it in a program and running that program in Python*. > >> Why do you ask? > > > > Your "sho

Re: Trailing zeros of 100!

2016-01-02 Thread Robin Koch
Am 02.01.2016 um 22:57 schrieb Chris Angelico: On Sun, Jan 3, 2016 at 3:56 AM, Robin Koch wrote: Am 02.01.2016 um 17:09 schrieb Tony van der Hoff: On 02/01/16 16:57, Robin Koch wrote: sum([int(0.2**k*n) for k in range(1, int(log(n, 5))+1)]) But did you actually test it? Yes, should wo

Re: Trailing zeros of 100!

2016-01-02 Thread Thomas 'PointedEars' Lahn
Mark Lawrence wrote: > Please don't top post, it's extremely annoying when trying to follow > long threads. As are full quotes. -- PointedEars Twitter: @PointedEars2 Please do not cc me. / Bitte keine Kopien per E-Mail. -- https://mail.python.org/mailman/listinfo/python-list

Re: Trailing zeros of 100!

2016-01-02 Thread Chris Angelico
On Sun, Jan 3, 2016 at 3:56 AM, Robin Koch wrote: > Am 02.01.2016 um 17:09 schrieb Tony van der Hoff: >> >> On 02/01/16 16:57, Robin Koch wrote: >>> >>> sum([int(0.2**k*n) for k in range(1, int(log(n, 5))+1)]) >> >> >> But did you actually test it? > > > Yes, should work for n >= 1. > > Why do you

Re: Trailing zeros of 100!

2016-01-02 Thread Mark Lawrence
On 02/01/2016 20:09, yehudak . wrote: Hi again, I looked a little deeper at your code. Smart solution and kudos. Yehuda Still top posting? Thanks a bunch. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mai

Re: Trailing zeros of 100!

2016-01-02 Thread Mark Lawrence
On 02/01/2016 20:02, yehudak . wrote: Hello vbr, That's EXACTLY what I needed. rstrip is new for me so I'm going to Dr. Google to learn. On my efforts I was struggling with .pop() but wasn't very successful... Thank you so much, Yehuda How many times do you have to be asked to not top post?

Re: Trailing zeros of 100!

2016-01-02 Thread yehudak .
Hi again, I looked a little deeper at your code. Smart solution and kudos. Yehuda On Sat, Jan 2, 2016 at 10:02 PM, yehudak . wrote: > Hello vbr, > That's EXACTLY what I needed. rstrip is new for me so I'm going to Dr. > Google to learn. > > On my efforts I was struggling with .pop() but wasn't

Re: Trailing zeros of 100!

2016-01-02 Thread yehudak .
Hello vbr, That's EXACTLY what I needed. rstrip is new for me so I'm going to Dr. Google to learn. On my efforts I was struggling with .pop() but wasn't very successful... Thank you so much, Yehuda On Sat, Jan 2, 2016 at 8:29 PM, Vlastimil Brom wrote: > 2016-01-02 18:34 GMT+01:00 yehudak . : >

Re: Trailing zeros of 100!

2016-01-02 Thread Vlastimil Brom
2016-01-02 18:34 GMT+01:00 yehudak . : [partly edited for bottom posting] > On Sat, Jan 2, 2016 at 5:24 PM, Vlastimil Brom > wrote: >> >> 2016-01-02 14:14 GMT+01:00 yehudak . : >> > [...]>> > On Sat, Jan 2, 2016 at 2:44 PM, Vlastimil Brom >> > >> > wrote: >> >> >> >> 2016-01-02 12:49 GMT+01:00 :

Re: Trailing zeros of 100!

2016-01-02 Thread Serhiy Storchaka
On 02.01.16 18:33, Tim Chase wrote: or mathematically: sum(1 for _ in itertools.takewhile( lambda x: n % (10**x) == 0, itertools.count(1))) The mathematician would prove that the result is not larger than 100/4. -- https://mail.python.org/mailman/listinfo/python-list

Re: Trailing zeros of 100!

2016-01-02 Thread Mark Lawrence
On 02/01/2016 17:34, yehudak . wrote: vbr, I tried using .pop() but could not get what I wanted .Also, I can't see an advantage in reversing the number. Would you care to write explicitly the program for me (and probably for other too)? Brute Force is the style I'm thinking about. Sorry, but I l

Re: Trailing zeros of 100!

2016-01-02 Thread yehudak .
vbr, I tried using .pop() but could not get what I wanted .Also, I can't see an advantage in reversing the number. Would you care to write explicitly the program for me (and probably for other too)? Brute Force is the style I'm thinking about. Sorry, but I learn most from viewing the code. Apprec

Re: Trailing zeros of 100!

2016-01-02 Thread Bernardo Sulzbach
On Sat, Jan 2, 2016 at 2:56 PM, Robin Koch wrote: > > Yes, should work for n >= 1. > The first power of 10 for which it fails in my machine is 10 ^ 17, which is not that much for modern computers. Discrete math should not meet floating points. I would post the "canonical" solution here if Peter

Re: Trailing zeros of 100!

2016-01-02 Thread Peter Otten
Robin Koch wrote: > Am 02.01.2016 um 12:49 schrieb katye2...@gmail.com: > >> I'm trying to write a python program to find how many trailing zeros >> are in 100! (factorial of 100). I used factorial from the math >> module, but my efforts to continue failed. Please help. > > Using not Python, but

Re: Trailing zeros of 100!

2016-01-02 Thread Robin Koch
Am 02.01.2016 um 17:09 schrieb Tony van der Hoff: On 02/01/16 16:57, Robin Koch wrote: sum([int(0.2**k*n) for k in range(1, int(log(n, 5))+1)]) But did you actually test it? Yes, should work for n >= 1. Why do you ask? -- Robin Koch -- https://mail.python.org/mailman/listinfo/python-list

Re: Trailing zeros of 100!

2016-01-02 Thread Tony van der Hoff
On 02/01/16 16:57, Robin Koch wrote: > sum([int(0.2**k*n) for k in range(1, int(log(n, 5))+1)]) But did you actually test it? -- Tony van der Hoff | mailto:t...@vanderhoff.org Ariège, France | -- https://mail.python.org/mailman/listinfo/python-list

Re: Trailing zeros of 100!

2016-01-02 Thread Tim Chase
On 2016-01-02 03:49, katye2...@gmail.com wrote: > I'm trying to write a python program to find how many trailing > zeros are in 100! (factorial of 100). I used factorial from the > math module, but my efforts to continue failed. Please help. Pretty easy to do with strings: from math import fact

Re: Trailing zeros of 100!

2016-01-02 Thread Robin Koch
Am 02.01.2016 um 14:14 schrieb yehudak .: Thank you so much, but... All that is Chinese for me. Can you show a 'normal' Python code for me? How about: >>> from math import log >>> sum([int(0.2**k*n) for k in range(1, int(log(n, 5))+1)]) }:-) (That implements my procedure in my other answe

Re: Trailing zeros of 100!

2016-01-02 Thread Robin Koch
Am 02.01.2016 um 12:49 schrieb katye2...@gmail.com: I'm trying to write a python program to find how many trailing zeros are in 100! (factorial of 100). I used factorial from the math module, but my efforts to continue failed. Please help. Using not Python, but math: Every "0" at the end of 1

Re: Trailing zeros of 100!

2016-01-02 Thread Mark Lawrence
On 02/01/2016 13:14, yehudak . wrote: Vlastimil, Thank you so much, but... All that is Chinese for me. Can you show a 'normal' Python code for me? Yehuda On Sat, Jan 2, 2016 at 2:44 PM, Vlastimil Brom wrote: 2016-01-02 12:49 GMT+01:00 : Hi, newbie here! I'm trying to write a python program

Re: Trailing zeros of 100!

2016-01-02 Thread Vlastimil Brom
2016-01-02 14:14 GMT+01:00 yehudak . : > Vlastimil, > Thank you so much, but... > All that is Chinese for me. > Can you show a 'normal' Python code for me? > > Yehuda > > On Sat, Jan 2, 2016 at 2:44 PM, Vlastimil Brom > wrote: >> >> 2016-01-02 12:49 GMT+01:00 : >> > Hi, newbie here! >> > I'm tryi

Re: Trailing zeros of 100!

2016-01-02 Thread Joel Goldstick
On Sat, Jan 2, 2016 at 8:14 AM, yehudak . wrote: > Vlastimil, > Thank you so much, but... > All that is Chinese for me. > Can you show a 'normal' Python code for me? > > Yehuda > > On Sat, Jan 2, 2016 at 2:44 PM, Vlastimil Brom > wrote: > > > 2016-01-02 12:49 GMT+01:00 : > > > Hi, newbie here!

Re: Trailing zeros of 100!

2016-01-02 Thread yehudak .
Vlastimil, Thank you so much, but... All that is Chinese for me. Can you show a 'normal' Python code for me? Yehuda On Sat, Jan 2, 2016 at 2:44 PM, Vlastimil Brom wrote: > 2016-01-02 12:49 GMT+01:00 : > > Hi, newbie here! > > I'm trying to write a python program to find how many trailing zeros

Re: Trailing zeros of 100!

2016-01-02 Thread Vlastimil Brom
2016-01-02 12:49 GMT+01:00 : > Hi, newbie here! > I'm trying to write a python program to find how many trailing zeros are in > 100! (factorial of 100). > I used factorial from the math module, but my efforts to continue failed. > Please help. > > Thank you, > Yehuda > -- > https://mail.python.o

Re: Trailing zeros of 100!

2016-01-02 Thread katye2007
On Saturday, January 2, 2016 at 1:49:47 PM UTC+2, katy...@gmail.com wrote: > Hi, newbie here! > I'm trying to write a python program to find how many trailing zeros are in > 100! (factorial of 100). > I used factorial from the math module, but my efforts to continue failed. > Please help. > > Th

Re: Trailing zeros of 100!

2016-01-02 Thread David
On 2 January 2016 at 22:49, wrote: > Hi, newbie here! Hi Yehuda > I'm trying to write a python program to find how many trailing zeros are in > 100! (factorial of 100). > I used factorial from the math module, but my efforts to continue failed. > Please help. There is a special mailing list