# take input
      num = int(input('Enter a number: '))
      # find sum of natural number
      sum = 0
      x = 1
      while x <= num:
       sum += x 
       sum += x 
       x += 1
       x += 1
      # display result
      print('The sum of natural number =', sum)
      
      Python language logo

      Sum Till end

      basicMaths
      beginner

      Sum of N Natural Numbers in Python

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.