Sum of first 10 prime numbers i given range using python | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 2

Sum of first 10 prime numbers i given range using python

help me solve out this. first find the prime numbers in n given range then sum of first 10 prime numbers

25th Mar 2018, 12:08 PM
Harry Singh
Harry Singh - avatar
3 Answers
+ 2
First do a for loop that runs through every number in range of input. Inside the for loop check for every number if it is prime by running a new function. In this function you can check if it's prime by getting all the dividors and then checking if the length of all dividors is 2. Then store all the primes in one list and run sum() on it. https://code.sololearn.com/c8VmCTEj1S4H/?ref=app
25th Mar 2018, 12:51 PM
Tim Thuma
Tim Thuma - avatar
+ 2
25th Mar 2018, 1:11 PM
Tim Thuma
Tim Thuma - avatar
+ 1
but this display only prime numbers .. no addition. but first one is ok
25th Mar 2018, 1:46 PM
Harry Singh
Harry Singh - avatar