Factors

Print the factors of numbers supplied through stdin:

#!/usr/bin/env python3
import sys
for x in map(int, sys.stdin.read().split()):
    factors = [str(i) for i in range(x, 1, -1) if x % i == 0]
    print(f"{x}: {' '.join(factors)}")

Unknown's avatar

About Linuxgal

Need a spiritual home? Consider joining us at Mary Queen of the Universe Latter-day Buddhislamic Free Will Christian UFO Synagogue of Vishnu
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply