for loop to add the first n numbers

Sdílet
Vložit
  • čas přidán 9. 09. 2024
  • for loop to add the first n numbers
    "Week: 3
    Topic: For loop to add the first n numbers" IIT Madras welcomes you to the world’s first BSc Degree program in Programming and Data Science. This program was designed for students and working professionals from various educational backgrounds and different age groups to give them an opportunity to study from IIT Madras without having to write the JEE. Through our online programs, we help our learners to get access to a world-class curriculum in Data Science and Programming.
    To know more about our Programs, please visit :
    BSc Degree in Programming and Data Science - onlinedegree.i...
    Diploma in Programming / Data Science - diploma.iitm.a...

Komentáře • 11

  • @anaskattar7283
    @anaskattar7283 Před 3 lety +5

    It was really nice of you to bring up The Story of Gauss.

  • @NimeLime
    @NimeLime Před 2 lety +6

    Sir it should be n+1 in the range part for for loop

  • @avenumadhav3568
    @avenumadhav3568 Před 3 lety +3

    problem statement: 2:03
    solution: 3:44 7:40(modification)

  • @reddygopichand2002
    @reddygopichand2002 Před 2 lety +1

    If 'n' starts from "0"
    8:00 sum of first n numbers:-
    n=int(input())
    print(((n*(n+1))/2)-n)

  • @nikhilatiitm
    @nikhilatiitm Před 2 lety +1

    1:41 i liked this video and also made the like count to 45

  • @sumit-ch1pz
    @sumit-ch1pz Před 2 lety +2

    It should be n+1 in range

  • @waliamayank
    @waliamayank Před 3 lety +3

    8:44 Sum of n natural nos. = n(n+1)/2

    • @madhavsuresh6066
      @madhavsuresh6066 Před 2 lety

      But that formula won't be right for this problem. For first n number, sir starts from 0 to n-1. Whereas the formula is 1 to n.

    • @reddygopichand2002
      @reddygopichand2002 Před 2 lety +1

      8:44 If you want to Start from 0
      Short ans:-
      n=int(input())
      print(((n*(n+1))/2)-n)

  • @madhavsuresh6066
    @madhavsuresh6066 Před 2 lety +1

    I feel that the sum of first n numbers should be starting from 1 not 0. 0 has no value in the sum.

  • @054_nirajkumar3
    @054_nirajkumar3 Před 3 lety +1

    थैंक्यू