Репост из: Code dasturi
def tub_sonmi(n):
if n < 2:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
son = int(input("Istalgan sonni kiriting: "))
if tub_sonmi(son):
print(son, " - tub son")
else:
print(son, " - tub son emas")
Ushbu dastur foydalanuvchi kiritgan sonning tub yoki tub son emasligini tekshiradi.
if n < 2:
return False
for i in range(2, int(n**0.5) + 1):
if n % i == 0:
return False
return True
son = int(input("Istalgan sonni kiriting: "))
if tub_sonmi(son):
print(son, " - tub son")
else:
print(son, " - tub son emas")
Ushbu dastur foydalanuvchi kiritgan sonning tub yoki tub son emasligini tekshiradi.