I am write procedure for write code sum of 1 to n numbers.
but It take more second to solve it.
like var a = 1 , var n = 12345678965487512 ,
var sum = 12345678965487513 ,
I am write procedure for write code sum of 1 to n numbers.
but It take more second to solve it.
like var a = 1 , var n = 12345678965487512 ,
var sum = 12345678965487513 ,
I am writing a program in
JavaScriptlanguage.Output:
5050
The program to find out sum of 1 to n number in python will be the following:
Output →
Input : 5
Output : Sum of first 5 natural numbers is: 15
This program take O(1) time.