I am not getting the output for this function | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

I am not getting the output for this function

Fill in the blanks to create a prime number generator, that yields all prime numbers in a loop. (Consider having an is_prime function already defined): def get_primes(): num = 2 while True: if is_prime(num): yield num num += 1 ##The output i am getting is NO OUTPUT......I am not getting the prime numbers

23rd May 2020, 7:23 AM
Ummadisetty . Lakshmi Venkata Mallikarjuna
Ummadisetty . Lakshmi Venkata Mallikarjuna - avatar
6 Answers
+ 4
you need to indent the while loop def get_primes(): num=2 while True: if is_prime(num): yield num num+=1
23rd May 2020, 10:41 AM
Prabhakar Dev
Prabhakar Dev - avatar
+ 1
def get_primes(): num=2 while True: if is_prime(num): yield num num+=1
19th Aug 2020, 10:30 PM
Silas Silikhe
0
You need to print using print function
23rd May 2020, 7:29 AM
A͢J
A͢J - avatar
0
here is my code def fibonacci(n): if n == 1 or n == 2 return 1 return fibonacci(n-1) + fibonacci(n-2) for i in range (1, 11): print(fibonacci(i))
27th Feb 2021, 10:39 PM
Matlou Macdonald Sekgaphola
Matlou Macdonald Sekgaphola - avatar
0
num= int(input()) def fibonacci(n): if n <= 1: return n; return fibonacci(n-1) + fibonacci(n-2) for i in range(num): print(fibonacci(i))
27th Feb 2021, 10:40 PM
Matlou Macdonald Sekgaphola
Matlou Macdonald Sekgaphola - avatar
0
question : Fill in the blanks to create a prime number generator, that yields all prime numbers in a loop. (Consider having an is_prime function already defined): program : def get_primes(): num = 2 while true: if is_prime(num): yield num num+=1
28th May 2021, 12:55 PM
Madhavareddy
Madhavareddy - avatar