There is a function to list the prime divisors or prime factors.
It is called prime_divisors
, and aliased as prime_factors
.
The len
function can then give the number of prime factors.
sage: a = 234
sage: prime_divisors(a)
[2, 3, 13]
sage: len(prime_divisors(a))
3
sage: prime_factors(a)
[2, 3, 13]
sage: len(prime_factors(a))
3
The function prime_divisors
and its alias prime_factors
also exist as methods of integers.
sage: a.prime_divisors()
[2, 3, 13]
sage: len(a.prime_divisors())
3
sage: a.prime_factors()
[2, 3, 13]
sage: len(a.prime_factors())
3