|
|
вернуться в форумC++ Solution with no loops Послано Maksim 3 июл 2024 16:30 Maybe someone will need it. You can read more about it here: https://en.wikipedia.org/wiki/Arithmetic_progression #include <iostream> using namespace std; int main() { int a; cin >> a; int result = a > 0 ? a * (a + 1) / 2 : - a * (a - 1) / 2 + 1; cout << result; } Edited by author 03.07.2024 16:31 Edited by author 03.07.2024 16:31 |
|
|