Pythonda bir son primo yoki nol ekanligini aniqlash uchun quyidagi kodni ishlatishingiz mumkin. ``` import math def is_prime(n): for i in range(2,int(math.sqrt(n))+1): if (n%i) == 0: return False return True while True: n = input("Primo ekanligini tekshirish uchun sonni kiriting. [0ni chiqarib tashlang]") if n == 0: print("Programmadan chiqing.") break is_prime(n) ``` Endi yuqoridagi funksiya ta'rifi bilan tanishib chiqaylik: - Funksiyani optimallashtirish va kamroq hisob-kitob qilish uchun, ushbu sonning kvadrat ildizini hisoblaymiz, Pythonning matematik modulidan math.sqrt.s modulidan foydalanib. - N mukammal kvadrat bo'lmasligi mumkin, shuning uchun biz uni butun songa aylantiram
spam fails_task lang_mismatch pii not_appropriate hate_speech sexual_content quality toxicity humor helpfulness creativity violence