我希望使用C ++语言编写一个程序,该程序将找到0到100之间的数字并被5整除,然后求和它们的总数
#include <cmath>
#include <iostream>
using namespace std;
// Returns sum of n digit numbers
// divisible by '5'
int totalSumDivisibleByNum(int n, int number)
{
// compute the first and last term
int firstnum = pow(10, n - 1);
int lastnum = pow(10, 5);
// sum of number which having
// n digit and divisible by number
int sum = 0;
for (int i = firstnum; i < lastnum; i++)
if (i % number == 0)
sum += i;
return sum;