Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
25
Task/Disarium-numbers/Python/disarium-numbers.py
Normal file
25
Task/Disarium-numbers/Python/disarium-numbers.py
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/python
|
||||
|
||||
def isDisarium(n):
|
||||
digitos = len(str(n))
|
||||
suma = 0
|
||||
x = n
|
||||
while x != 0:
|
||||
suma += (x % 10) ** digitos
|
||||
digitos -= 1
|
||||
x //= 10
|
||||
if suma == n:
|
||||
return True
|
||||
else:
|
||||
return False
|
||||
|
||||
if __name__ == '__main__':
|
||||
limite = 19
|
||||
cont = 0
|
||||
n = 0
|
||||
print("The first",limite,"Disarium numbers are:")
|
||||
while cont < limite:
|
||||
if isDisarium(n):
|
||||
print(n, end = " ")
|
||||
cont += 1
|
||||
n += 1
|
||||
Loading…
Add table
Add a link
Reference in a new issue