Computer Science, asked by hk610166785, 1 month ago


Algorithum to find sum of first
natural numbers​

Answers

Answered by mallimounika6
0

Explanation:

use this step to solve or give me the correct questions i will send the answr

Attachments:
Answered by HarishAS
0

ANSWER :

Method 1 :

Step 1: Getting number of terms 'n' required as input from the user.

Step 2: Assinging some variable 'x' the value 0

Step 3: Using a for loop from 1 to n to add those values to the x.

Step 4: Printing x. This x will be the sum of n natural numers.

Method 2 :

Step 1: Getting number of terms 'n' required as input from the user.

Step 2: Printing n*(n+1)/2 will directly gives the sum of first n natural numbers.

Hope this helps : )

Similar questions