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
- Sum of the sequence 2, 22, 222, .........
- Look-and-Say Sequence
- Aronson's Sequence
- k-th number in the Odd-Even sequence
- Gould's Sequence
- Connell Sequence
- Find F(n) when F(i) and F(j) of a sequence are given
- Alcuin's Sequence
- Gijswijt's Sequence
- Increasing sequence with given GCD
- Sylvester's sequence
- Padovan Sequence
- Juggler Sequence
- Farey Sequence
- Recaman's 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 firstname.lastname@example.org. 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