From 0301175d9939ccb2ef05d92035a53f03a6ddb988 Mon Sep 17 00:00:00 2001 From: Vipin Karthic Date: Tue, 10 Oct 2023 13:38:32 +0530 Subject: [PATCH] Added doctests to carmichael_number.py --- maths/carmichael_number.py | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/maths/carmichael_number.py b/maths/carmichael_number.py index 81712520f..dff0204b9 100644 --- a/maths/carmichael_number.py +++ b/maths/carmichael_number.py @@ -24,6 +24,20 @@ def power(x: int, y: int, mod: int) -> int: def is_carmichael_number(n: int) -> bool: + """ + Doctests : + >>> is_carmichael_number(561) + True + >>> is_carmichael_number(1105) + True + >>> is_carmichael_number(4) + False + >>> is_carmichael_number(8911) + True + >>> is_carmichael_number(900) + False + """ + b = 2 while b < n: if greatest_common_divisor(b, n) == 1 and power(b, n - 1, n) != 1: