top button
Flag Notify
    Connect to us
      Site Registration

Site Registration

Give an algorithm to find nth number generated from list of prime numbers?

+5 votes
576 views

Example :
Let the list be {2,3,5} and Assume always 1 be included then

2th number is 2
3th number is 3
4th number is 4
5th number is 5
6th number is 6
7th number is 8
8th number is 9
9th number is 10
10th number is 12
11th number is 15 and so on...

posted Nov 24, 2013 by Raghu

Share this question
Facebook Share Button Twitter Share Button LinkedIn Share Button
I hope I understood correctly, but how 6th prime number can be 6 (6 is not prime)

Also check if it helps to find a prime number
if a^n mod n = a mod n then n is a prime number, choose a as 2. its called Fermat's Little Theorem.

1 Answer

+2 votes

Salil: Raghu is asking for Hamming Sequnce.

Raghu: Please see the following link should be helpful.
http://web.cecs.pdx.edu/~black/AdvancedProgramming/Lectures/Hamming%20Closures/Hamming-6up.pdf

answer Nov 24, 2013 by Jai Prakash
Thanks alot Jai Prakash, This was really very helpful.
Similar Questions
+3 votes

A list contains a set of numbers, one number presents once and other numbers present even no. of times. Find out the number that occurs once in the list.

+2 votes

Say we only know the worst case and best case complexity of an algo (Algo is not known). Is it possible to get the average case complexity?

+4 votes

If we delete the mth number from a circle which is composed of numbers 0, 1, …, n-1 counting from 0 at every time, what is the last number?

For example, a circle is composed of five numbers 0, 1, 2, 3, 4. If we delete the 3rd number at every time, the deleted numbers are in order of 2, 0, 4, 1, so the last remaining number is 3.

...