Skip to content

Created harshad_numbers.py #9023

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 20 commits into from
Sep 6, 2023
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
Prev Previous commit
Next Next commit
Update harshad_numbers.py
Fixed depreciated Tuple and List usage
  • Loading branch information
davidekong authored Aug 31, 2023
commit 44eb28623bff4700d879f2fc623cf1bf58854acb
4 changes: 1 addition & 3 deletions maths/harshad_numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
Reference: https://en.wikipedia.org/wiki/Harshad_number
"""

from typing import Tuple, List


def int_to_base(number: int, base_of_interest: int) -> str:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As there is no test file in this pull request nor any test function or class in the file maths/harshad_numbers.py, please provide doctest for the function int_to_base

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As there is no test file in this pull request nor any test function or class in the file maths/harshad_numbers.py, please provide doctest for the function int_to_base

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As there is no test file in this pull request nor any test function or class in the file maths/harshad_numbers.py, please provide doctest for the function int_to_base

digits = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
Expand Down Expand Up @@ -55,7 +53,7 @@ def sum_of_digits(num: int, base_of_interest: int) -> str:
return res


def all_harshad_numbers(num: int, base_of_interest: int) -> Tuple[int, List[str]]:
def all_harshad_numbers(num: int, base_of_interest: int) -> tuple[int, list[str]]:
"""
Finds all Harshad numbers smaller than num in base 'base_of_interest'.
Where 'base_of_interest' ranges from 2 to 36.
Expand Down