1 #include <iostream> 2 3 using namespace std; 4 long long sum(long long n); 5 6 int main() 7 { 8 long long n; 9 while(cin >> n) 10 cout << sum(n) << endl << endl; 11 return 0; 12 } 13 14 long long sum(long long n) 15 { 16 return (1 + n) * n / 2; 17 }
时间: 2024-12-25 01:26:56