#include <iostream>
using namespace std;
int main()
{
int n, k, s = 0;
cin >> n >> k;
for (int i = 0; i <= n; i++)
if (i % k == 0)
s += i;
}
cout << s;
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
#include <iostream>
using namespace std;
int main()
{
int n, k, s = 0;
cin >> n >> k;
for (int i = 0; i <= n; i++)
{
if (i % k == 0)
{
s += i;
}
}
cout << s;
}