+ 7

[Challenge] Harshad Numbers

Greetings, Sololearners! Welcome to another challenge! A Harshad Number is a number that is divisible by the sum of its digits. For example, 18 is a Harshad number as its digital root is 1+8 = 9, and as 18 % 9 == 0, it is a Harshad number. Your task: Write a program that identifies if a number is a Harshad number. If it is Harshad, return True. If not, return the next Harshad number. Example 1: 1 Output: True Example 2: 24 Output: True Example 3: 73 Output: 80 Good luck, and have fun!

14th Oct 2017, 9:21 AM
blackcat1111
blackcat1111 - avatar
10 Réponses
14th Oct 2017, 12:14 PM
Krishna Teja Yeluripati
Krishna Teja Yeluripati - avatar
15th Oct 2017, 4:43 AM
Amit Dubey
Amit Dubey - avatar
15th Oct 2017, 4:53 PM
Abhishek Tandon
Abhishek Tandon - avatar
+ 4
https://code.sololearn.com/cbM6fLLVsCgN/?ref=app
25th Oct 2017, 1:54 PM
Saransh Bhatia
Saransh Bhatia - avatar
+ 3
a=int(input()) sum=0 for i in str(a):sum+=int(i) print(a%sum==0) #python
14th Oct 2017, 3:07 PM
👑 Prometheus 🇸🇬
👑 Prometheus 🇸🇬 - avatar
+ 2
My try in python. Do feel free to comment on how I can improve my code to make it simpler and neater! :) I'm quite new to coding :) https://code.sololearn.com/cM1BY2UL26mW/?ref=app
15th Oct 2017, 7:40 AM
Magg
15th Oct 2017, 11:22 AM
Saurabh Tiwari
Saurabh Tiwari - avatar
30th Oct 2017, 11:35 AM
Pranit Gandhi
Pranit Gandhi - avatar
2nd Jan 2019, 4:28 PM
Azeddine Hamdaoui
Azeddine Hamdaoui - avatar
+ 1
https://code.sololearn.com/ccThPC5yHfXu/#cs
30th Oct 2017, 3:27 PM
Veres Roland
Veres Roland - avatar