Skip to content

Instantly share code, notes, and snippets.

@mit41301
Created September 16, 2026 06:48
Show Gist options
  • Select an option

  • Save mit41301/54708bfe2d4ea9450cc0bc7b5bba2d50 to your computer and use it in GitHub Desktop.

Select an option

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
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