W
W
whatislov2020-11-02 22:34:58
C++ / C#
whatislov, 2020-11-02 22:34:58

How to find the sum of numbers in the range from 1 to n (n is entered by the user), step 1?

How to find the sum of numbers between 1 and n(user input), step 1, through a loop?
Entered for example 5, displays
1
2
3
4
5
How can I calculate the sum of digits from 1 to n (roughly speaking).

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alexander Ananiev, 2020-11-03
@whatislov

Get a counter (variable) and in a cycle from 1 to n add one to the counter.
Or use the formula for calculating the sum for an arithmetic progression.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question