1.5 10: Accumulation of numbers that meet the conditions

Description
Accumulate the numbers between the positive integers m and n (including m and n) that are divisible by 17. Among them, 0 <m <n <1000.

Enter a
line containing two integers m and n, separated by a space.
Output
Output one line, including an integer, indicating the result of accumulation.
Sample input
50 85
Sample output
204

#include <iostream>
using namespace std;
int main()
{
    
    
	int m, n, r, sum=0, temp;
	cin >> m >> n;
	for(int i=m;i<=n;i++)
	{
    
    
		if(i%17==0)
		{
    
    
			sum+=i;
		}
	}
	cout<<sum<<endl;
	return 0;
}

Guess you like

Origin blog.csdn.net/yansuifeng1126/article/details/111994428