You are given a positive integer n. Your task is to find and print the sum of the first n natural numbers, that is, add all numbers starting from 1 up to n and return the final sum.
The result should be displayed as a single integer.
Topics
Companies
Articles
Examples:
N/A
Constraints:
1 < n < 106
n is a positive integer.
Companies:
MicrosoftSamsungWalmart
Topics:
Recursion
Please log in to access the Submissions tab, where you can review your progress and explore code submissions from other participants.
Please log in to access the Solution tab and view detailed answers and explanations.
Please log in to access the Discussion tab and join conversations with other participants.
Access Restricted: Please Login to access the code editor and test cases.