Given a number ‘n’, generate the first ‘n’ terms of the Smarandache-Wellin Sequence.
The Smarandache-Wellin Sequence is a sequence formed by the Smarandache-Wellin numbers. Each Smarandache-Wellin number that make up the sequence is obtained by concatenating the consecutive prime numbers beginning from the first prime number i.e, 2. Thus, the first term of the sequence is 2, second term is 23, third term is 235, …. Similarly, the ‘n’th term is made up by concatenating the first ‘n’ prime numbers beginning from the first prime number i.e, 2.
Input : 5 Output : 2 23 235 2357 235711 Input : 10 Output : 2 23 235 2357 235711 23571113 2357111317 235711131719 23571113171923 2357111317192329
1) Initially find the first ‘n’ prime numbers and store them in a list.
2) Next, concatenate each term of the list beginning from the first term and increasing the length of the concatenated term each time by one.
3) Keep printing the concatenated terms so formed, each time, to generate the sequence.
Below is the implementation in Python.
First 5 terms of the Sequence are 2 23 235 2357 235711
- Look-and-Say Sequence
- Sum of the sequence 2, 22, 222, .........
- Aronson's Sequence
- k-th number in the Odd-Even sequence
- Sylvester's sequence
- Golomb sequence
- Gould's Sequence
- Connell Sequence
- Juggler Sequence
- Padovan Sequence
- Aliquot Sequence
- Farey Sequence
- Recaman's sequence
- Increasing sequence with given GCD
- Moser-de Bruijn Sequence
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.
Improved By : Mithun Kumar