Tech Study

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.

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

Result

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

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

Java Final keyword

Introduction : java final keyword The final keyword present in Java programming language is generally used for restricting the user. …

Read more

C++ Memory Management: new and delete

C++ Memory Management We know that arrays store contiguous and the same type of memory blocks, so memory is allocated …

Read more