İçeriğe geç

Python ile Project Euler Soru 7Çözümü

Sorunun orjinali:

By listing the first six prime numbers: 2, 3, 5, 7, 11, and 13, we can see that the 6th prime is 13.

What is the 10 001st prime number?

# Projecteuler 7. soru
def asalmı(sayı):
    karekok=int(sayı**(1/2))
    for i in range(3,karekok+1,2):
        if sayı%i==0:
            return False
    return True
sayac = 1
asalSayac = 1
while True:
    sayac += 2
    if asalmı(sayac):
        asalSayac+=1
    if asalSayac==10001:
        break
print("10001. asal sayı =", sayac)
503 Gösterim  
Tarih:algoritmalar ve programlamaya girişProject Euler

İlk Yorumu Siz Yapın

Bir cevap yazın

E-posta hesabınız yayımlanmayacak.

This site uses Akismet to reduce spam. Learn how your comment data is processed.