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 incompatible types in assignments
  • Loading branch information
davidekong authored Aug 31, 2023
commit ad09b82e537d8e8c1c23cdd0cbabc0506296607a
4 changes: 2 additions & 2 deletions maths/harshad_numbers.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def sum_of_digits(num: int, base_of_interest: int) -> str:
if (base_of_interest > 36) or (base_of_interest < 2):
raise ValueError("'base_of_interest' must be between 36 and 2 inclusive")

num = int_to_base(num, base_of_interest)
num_str = int_to_base(num, base_of_interest)
res = 0
for char in num:
for char in num_str:
res += int(char, base_of_interest)
res = int_to_base(res, base_of_interest)
return res
Expand Down