Another interesting example might be to extract all the prime numbers in a given interval. This code is shorter and more efficient than its equivalent for loop. As a result, you get a list of the even numbers. I can't change this code but the one above is what I wrote and can be changed. The call to filter() does the hard work and filters out the odd numbers. The point is the for _ in range(k): already prints out number which includes numbers I don't want printed out: This is the desired kind of output I want:for n=10 I want it to print out: That's the code I added but here is the code that's locked on which I have to write the code above to make it print the number one at a time def positive_integers_generator(): Here is my solution: def manipulate_generator(generator, n): please let me know the idea to print only 1st n non prime numbers: I cant comment the printing part of 1.n as it is blocked. 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.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |