school

thing1's amazing school repo
Log | Files | Refs | Submodules | README

exersise.py (422B)


      1 def getdigits(number):
      2         digits = []
      3         for i in number:
      4                 digits.append(int(i))
      5         return digits
      6 
      7 def testnumber(number):
      8 	d = getdigits(number)
      9 	total = sum(d)
     10 
     11 	if (int(number) % total) == 0:
     12         	return True
     13 	return False
     14 
     15 n = int(input("which harshad number should you go to: "))
     16 
     17 count = 0
     18 i = 0
     19 while count < n:
     20 	i += 1
     21 	if testnumber(str(i)):
     22                 count += 1
     23 
     24 print(i)