+ 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!
10 odpowiedzi
+ 15
+ 4
Java code for this :
https://code.sololearn.com/crvt6Hvfda0i/?ref=app
+ 4
Here's mine in C++
https://code.sololearn.com/cb6BXzTNUg1f/?ref=app
+ 4
https://code.sololearn.com/cbM6fLLVsCgN/?ref=app
+ 3
a=int(input())
sum=0
for i in str(a):sum+=int(i)
print(a%sum==0)
#python
+ 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
+ 2
here is mine...😇
https://code.sololearn.com/c46f088tAO41/?ref=app
+ 2
Mine here in Java:
https://code.sololearn.com/cp5BZoamQlXo/#java
+ 1
https://code.sololearn.com/ccThPC5yHfXu/#cs