fork download
  1. def is_prime(n):
  2. """Checks if a number is prime."""
  3. if n <= 1:
  4. return False
  5. for i in range(2, int(n**0.5) + 1):
  6. if n % i == 0:
  7. return False
  8. return True
  9.  
  10. prime_sum = 0
  11. count = 0
  12. num = 2
  13.  
  14. while count < 200:
  15. if is_prime(num):
  16. prime_sum += num
  17. count += 1
  18. num += 1
  19.  
  20. print("The sum of the first 200 prime numbers is:", prime_sum)
Success #stdin #stdout 0.04s 9756KB
stdin
Standard input is empty
stdout
The sum of the first 200 prime numbers is: 111587