With regards to the first problem, it is pretty easy if you can have all the primes precomputed. As a matter of fact, if you search the net, you'll find the list of all prime no.s that can be stored as a 4 byte unsigned integer !!. Just use that list of primes to find out the nearest with the help of binary search.
Else, you may also try the "sieve of eratosthenes" to compute prime numbers at run time, but I guess in the long run, the above method is better due to rduced computation. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to algogeeks@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/algogeeks -~----------~----~----~----~------~----~------~--~---