maths.special_numbers.carmichael_number

== Carmichael Numbers == A number n is said to be a Carmichael number if it satisfies the following modular arithmetic condition:

power(b, n-1) MOD n = 1, for all b ranging from 1 to n such that b and n are relatively prime, i.e, gcd(b, n) = 1

Examples of Carmichael Numbers: 561, 1105, … https://en.wikipedia.org/wiki/Carmichael_number

Attributes

number

Functions

is_carmichael_number(→ bool)

Examples:

power(→ int)

Examples:

Module Contents

maths.special_numbers.carmichael_number.is_carmichael_number(n: int) bool

Examples: >>> is_carmichael_number(4) False >>> is_carmichael_number(561) True >>> is_carmichael_number(562) False >>> is_carmichael_number(900) False >>> is_carmichael_number(1105) True >>> is_carmichael_number(8911) True >>> is_carmichael_number(5.1) Traceback (most recent call last):

ValueError: Number 5.1 must instead be a positive integer

>>> is_carmichael_number(-7)
Traceback (most recent call last):
     ...
ValueError: Number -7 must instead be a positive integer
>>> is_carmichael_number(0)
Traceback (most recent call last):
     ...
ValueError: Number 0 must instead be a positive integer
maths.special_numbers.carmichael_number.power(x: int, y: int, mod: int) int

Examples: >>> power(2, 15, 3) 2 >>> power(5, 1, 30) 5

maths.special_numbers.carmichael_number.number