Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

find difference between two triangular numbers python

#difference between triangular numbers

num1 = n=9
y=((n**2)+n)/(2)   
print (y)

num2 = n=6
y1=((n**2)+n)/(2)   
print (y1)

num1 =y
num2 =y1


if num1 > num2:
    diff= num1 - num2

else:
    diff= num2 - num1

print('The difference between 9th and 6th triangular numbers =',diff)
 
PREVIOUS NEXT
Tagged: #find #difference #triangular #numbers #python
ADD COMMENT
Topic
Name
9+3 =