From 7384865ba57062313bac2adc020a2d62f3369b23 Mon Sep 17 00:00:00 2001 From: Joe-rq <77777313+Joe-rq@users.noreply.github.com> Date: Sat, 6 Jul 2024 10:48:31 +0000 Subject: [PATCH] =?UTF-8?q?Master=20=E6=B7=BB=E5=8A=A0=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=B3=A8=E9=87=8A?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- mycode.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/mycode.py b/mycode.py index 589f06748..b06361ed3 100644 --- a/mycode.py +++ b/mycode.py @@ -1,3 +1,25 @@ +def is_prime(n): + """ + 返回一个布尔值,判断参数n是否为质数 + + 参数: + n (int): 需要检查的整数 + + 返回值: + bool: 如果n是质数,返回True;否则返回False + + """ + if n < 2: + return False + if n == 2: + return True + for m in range(2, int(n**0.5)+1): + if (n % m) == 0: + return False + else: + return True + +print(is_prime(11)) def is_prime(n): """ Return a boolean value based upon