Created
September 16, 2026 06:48
-
-
Save mit41301/54708bfe2d4ea9450cc0bc7b5bba2d50 to your computer and use it in GitHub Desktop.
Sum of the first N natural numbers using FOR...NEXT loop instead of using the formula
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 10 REM The sum of the first N natural numbers | |
| 20 INPUT " Enter last natural number = ",N | |
| 30 SUM=0 | |
| 40 FOR I=0 TO N | |
| 50 SUM=SUM+I | |
| 60 NEXT I | |
| 70 PRINT " Sum of all the natural numbers = ",SUM | |
| 80 END |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment