Code needs functions that returns whether a number is Triangular and if it's Narcissist. Main function:
def main():
playing = True
while playing == True:
num_input = input('Give me a number from 1 to 10000. Type -1 to exit. ')
try:
num = int(num_input)
if (num == -1):
playing = False
continue
if (num <= 0 or num > 10000):
continue
factors = getFactors(num)
print("The factors of", num, "are", factors)
if isTriangular(num):
print(str(num) + ' is triangular')
if isNarcissistic(num):
print(str(num) + ' is narcissistic')
Little I was able to achieve:
def isTriangular(x):
if x = (x + (x +1)) / 2 => 0:
return isTriangular(x)
def isNarcissistic(x):
question from:https://stackoverflow.com/questions/65886923/python-triangular-and-narcissist-numbers-functions