[algogeeks] Re: how to find Previous Prime number?

2005-11-29 Thread SUDARSHAN IYENGAR
factoring is an np complete problem. No change of having a simple algorithm for it. -sudarshan - Original Message - From: "Dhyanesh" <[EMAIL PROTECTED]> To: Sent: Wednesday, November 30, 2005 7:47 AM Subject: [algogeeks] Re: how to find Previous Prime number? I believe there is an N^

[algogeeks] Re: how to find Previous Prime number?

2005-11-29 Thread Venkatesh Dayalan
dhaynesh. can u pls elaborate ur soln with resplect to the context of this problem..On 11/30/05, Dhyanesh <[EMAIL PROTECTED] > wrote:I believe there is an N^12 algorithm for integer factorization ... so it isnt all that hard i think ...On 11/29/05, SUDARSHAN IYENGAR <[EMAIL PROTECTED]> wrote:>>

[algogeeks] Re: how to find Previous Prime number?

2005-11-29 Thread Venkatesh Dayalan
I do know there exixts a simple soln like yours. I am not asking abt Primality testing. When i am talking abt such a high range, the primes are obviously very sparse. So selecting 10 wont do. On 11/29/05, Arunachalam <[EMAIL PROTECTED]> wrote: I think it is simple,   The ratio of prime numb

[algogeeks] Re: Comparison of running times.

2005-11-29 Thread Abhi
for Q2 just solve the equation 100n^2 = 2^n :-) Abhi

[algogeeks] Comparison of running times.

2005-11-29 Thread nag
Q1. Suppose we are comparing implementations of insertion sort and merge sort on the same machine. For inputs of size n, insertion sort runs in 8n^2 steps, while merge sort runs in 64n lg n steps. For which values of n does insertion sort beat merge sort? Q2. What is the smallest value of n suc

[algogeeks] Re: One of the progimg prob given in ssn

2005-11-29 Thread pramod
How about this: The only reversals that increase the price are 2 --> 5 and 6 --> 9. We traverse from right-most digit to left-most digit and see if it's a 2 or a 5, if it is, then we reverse and thus we get the probable next max value. Next we sort the digits present in the number and for each

[algogeeks] One of the progimg prob given in ssn

2005-11-29 Thread sai ram
Hi,Can someone describe me a solution to this good problem ? How do yousolve it ? I have been thinking over but couldn't figure out one . Thisappeared in one of the recent contests that has been posted in the group. Problem Description *** Many departmental store use plastic dig

[algogeeks] Re: how to find Previous Prime number?

2005-11-29 Thread Dhyanesh
I believe there is an N^12 algorithm for integer factorization ... so it isnt all that hard i think ... On 11/29/05, SUDARSHAN IYENGAR <[EMAIL PROTECTED]> wrote: > > primality testing is a very very very tough topic to discuss... > > > There is no single algorithm for primality testing... and all

[algogeeks] Re: how to find Previous Prime number?

2005-11-29 Thread Arunachalam
I think it is simple,   The ratio of prime numbers to the normal number is quite high. ( may be 10 : 1). so loop backwards. and check whether a number is prime or not using Miller Rabin Test.(If you dont know about this test just google it). If it passes for randomly selected numbers( use some

[algogeeks] Re: how to find Previous Prime number?

2005-11-29 Thread SUDARSHAN IYENGAR
primality testing is a very very very tough topic to discuss... There is no single algorithm for primality testing... and all that is known so far is nothing but intelligent brute forcing... try peeping through http://primepages.org more like a bible for prime number lovers. -Sudarshan The

[algogeeks] Re: how to find Previous Prime number?

2005-11-29 Thread Venkatesh Dayalan
thanks for the info but i am looking into the logic of finding the previous prime number... On 11/29/05, SUDARSHAN IYENGAR <[EMAIL PROTECTED]> wrote: hey well... you must have a look at this package "pari gp"try googling and you can download this package, its very small and is thebest of its ki

[algogeeks] Re: how to find Previous Prime number?

2005-11-29 Thread SUDARSHAN IYENGAR
hey well... you must have a look at this package "pari gp" try googling and you can download this package, its very small and is the best of its kind available till date... You can also get the code for the same... -Sudarshan - Original Message - From: <[EMAIL PROTECTED]> To: "Algorith

[algogeeks] how to find Previous Prime number?

2005-11-29 Thread [EMAIL PROTECTED]
Hi everbody Given a number which can be as long as 1 digits, is there a method to find the previous prime number to it? ~venkatesh