Algorithm to find the sum of n natural numbers

preview_player
Показать описание
After a long time , I am doing this video on Algorithms as I see most of my subscribers requesting me for videos on algorithms.

Here I have done a small mistake. used N and n in the algorithm.
please use either N or n. not both.
Рекомендации по теме
Комментарии
Автор

For why this formulae works, aka how this formulae is derived.
You can google Arithmatic Progressions, Sum of n numbers of an AP formulae.

The formulae states that to find the sum of 1st n number's of an AP:
n = number of terms
a = first term
d = additive difference (can be negative for a decreasing AP)
l = last term

=> n/2 (2a + (n - 1)d)
and there is one more formulae if you know the last term,
=> n/2 (a + l)

Here in this algo, we used the second formulae as it is also an AP: 1, 2, 3, 4, 5 ... n with a = 1, d = 1, l = n

krishgarg
Автор

Please tell & flowchert to find largest of N numbers.

ashokchaudhary
Автор

can you find the complexity of this Algorithem ?

saudalotayfi
Автор

Sir why did you removed pega videos from your channel? And looks your channel is also not available for some days?

anilbabu