help me to implement a short C program that works with factorization of integers it is supposed to compute and print out the sum of all natural numbers below
100,000 that are multiples of 3,5 or 7.
if asked to sum all the natural numbers below 20 which are multiples of 3,5 or 7,The answer is 99 (that is, 3+5+7+9+10+12+14+15+18). To compute this of course,i enumerated all the natural numbers up to 20 and added to the sum (which starts out at zero),
only those which are multiples of one of the numbers requested.
so help me do the above, but for all such numbers less than 100,000.

Recommended Answers

All 4 Replies

Well, can't you just change the algorithm you used for the limit of 20 and adjust it to 100000? Perhaps you can post the code you have already.

Use the modulus operator (%) to find the numbers that give a remainder of zero for 3,5,or 7 (or being "||"). Use a loop to add them for a total sum.

Use a for loop and modulus operator.

Use a for loop and modulus operator.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.