Search
 
SCRIPT & CODE EXAMPLE
 

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)
Comment

PREVIOUS NEXT
Code Example
Python :: python sort by last name using lambda 
Python :: critical errors python 
Python :: how to count discord chat messages with python 
Python :: matplotlib gfg 
Python :: appropriate graph for dataset visualization 
Python :: restart kernel python 
Python :: create date by column values pandas 
Python :: what will be the output of the following python code? x = 123 for i in x: print(i) 
Python :: biopython parse fasta 
Python :: custom point annotation pyplot scatter 
Python :: Dataframe with defined shape filled with 0 
Python :: upload file to SQL server pyodbc python 
Python :: def print_seconds(hours minutes seconds) print() print_seconds(1 2 3) 
Python :: some problem occurred shows payubiz 
Python :: short name in python 
Python :: tkinter centre a button on 1920x1080 
Python :: how to add previous and next in tkinter in python 
Python :: tkinter titre fenetre 
Python :: python selenium canvas fingerprinting 
Python :: django rest framework foreign key relation giving error in serializer 
Python :: The module in NAME could not be imported: django.contrhtmlib.auth.password_validation.UserAttributeSimilarityValidator. Check your AUTH_PASSWORD_VALIDATORS setting. 
Python :: red black tree python 
Python :: python sha256 crypt decrypt 
Python :: pyspark rdd sort by value descending 
Python :: geopy set proxy 
Python :: integer to boolean numpy 
Python :: count number of repeats in list python 
Python :: api csv python 
Python :: break py 
Python :: how to get azure keyvalaut values into python function app 
ADD CONTENT
Topic
Content
Source link
Name
8+8 =