Skip to content

Update basic_maths.py #1517

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Oct 29, 2019
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions maths/basic_maths.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@


def prime_factors(n):
"""Find Prime Factors."""
"""Find Prime Factors.
>>> prime_factors(10)
[2,5]
"""
pf = []
while n % 2 == 0:
pf.append(2)
Expand All @@ -21,7 +24,10 @@ def prime_factors(n):


def number_of_divisors(n):
"""Calculate Number of Divisors of an Integer."""
"""Calculate Number of Divisors of an Integer.
>>> number_of_divisors(24)
8
"""
div = 1

temp = 1
Expand All @@ -41,7 +47,10 @@ def number_of_divisors(n):


def sum_of_divisors(n):
"""Calculate Sum of Divisors."""
"""Calculate Sum of Divisors.
>>> sum_of_divisors(72)
195
"""
s = 1

temp = 1
Expand Down