[algogeeks] Re: Generate random number from 1 to 10.

2014-02-12 Thread SVIX
Thanks for the explanation Don! It looks like I need better math-foo to completely understand your explanation... On Tuesday, February 11, 2014 10:07:05 AM UTC-8, Don wrote: > > > It can be shown mathematically that if you use a multiplier A such that > A*2^15-1 and A*2^16-1 are both prime, you

Re: [algogeeks] Find 3 digit number.

2014-02-12 Thread Don
I like that Python code, and for three digits numbers it is just fine. If the number could be in a larger range, factoring out digits starting with larger digits should give the correct sequence, in reverse. If the number has a prime factor larger than 9, there is no solution. // Returns the sm

Re: [algogeeks] Find 3 digit number.

2014-02-12 Thread Shashwat Anand
Since the limit is so small, won't a simple bruteforce do ? Just run a loop from [100, 1000) and return the minimum. Here is a quick python code I wrote. >>> N = 24 >>> min (i for i in range (100, 1001) if int (str (i) [0]) * int (str (i) [1]) * int (str (i) [2]) == N) 138 >>> N = 36 >>> min (i

[algogeeks] Find 3 digit number.

2014-02-12 Thread atul anand
Given a number N, find the smallest 3 digits number such that product of its digits is equal to N. For Eg:- for input 24 , output :138 (1*3*8 = 24) for input 36 , output :149 (1*4*9 = 36) for input 100 , output : 455 (4*5*5 = 100) -- You received this message because you are subscribed to the