Write a python program to sum of the first n positive integers


Introduction

Write a python program to sum of the first n positive integers. I have used python 3.7 compiler for debugging purpose.


techstudy.org

HP 15 Core i3 7th gen Laptop(4GB, 1TB HDD, Windows 10) | Rs. 31,490

  1. num = int(input("Input a number: "))
  2. sum_num = (num * (num + 1)) / 2
  3. print(sum_num)

Result

python language techstudy.org

     





Related Topics




Popular Posts