Mar-01-2019, 07:44 AM
I have a hackkerank coding challenge to print first n non prime numbers, i have the working code but the problem is that they have a locked code which prints numbers from 1 to n along with the output, in order to pass the test i need to print only the non prime numbers not 1...n numbers along with it. I cant comment the printing part of 1...n as it is blocked. please let me know the idea to print only 1st n non prime numbers
1
[1]
[1]
2
[1, 4]
[1, 4]
3
[1, 4, 6]
[1, 4, 6]
4
[1, 4, 6, 8]
5
[1, 4, 6, 8, 9]
6
[1, 4, 6, 8, 9, 10]
[1, 4, 6, 8, 9, 10]
7
[1, 4, 6, 8, 9, 10, 12]
[1, 4, 6, 8, 9, 10, 12]
8
[1, 4, 6, 8, 9, 10, 12, 14]
9
[1, 4, 6, 8, 9, 10, 12, 14, 15]
10
[1, 4, 6, 8, 9, 10, 12, 14, 15, 16]
[1, 4, 6, 8, 9, 10, 12, 14, 15, 16]
11
[1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18]
[1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18]
12
[1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20] my output
expected output
1
4
6
8
9
10
12
14
15
16
18
20
1
[1]
[1]
2
[1, 4]
[1, 4]
3
[1, 4, 6]
[1, 4, 6]
4
[1, 4, 6, 8]
5
[1, 4, 6, 8, 9]
6
[1, 4, 6, 8, 9, 10]
[1, 4, 6, 8, 9, 10]
7
[1, 4, 6, 8, 9, 10, 12]
[1, 4, 6, 8, 9, 10, 12]
8
[1, 4, 6, 8, 9, 10, 12, 14]
9
[1, 4, 6, 8, 9, 10, 12, 14, 15]
10
[1, 4, 6, 8, 9, 10, 12, 14, 15, 16]
[1, 4, 6, 8, 9, 10, 12, 14, 15, 16]
11
[1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18]
[1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18]
12
[1, 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 20] my output
expected output
1
4
6
8
9
10
12
14
15
16
18
20