How to get multiples of a certain number | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

How to get multiples of a certain number

10th Jun 2021, 11:40 PM
Ricky Mills
Ricky Mills - avatar
3 Answers
+ 1
Are you wanting to get N amount of multiples of a number, or all factors of a multiple? I.E. Number = 5 N = 4 Multiples = {5, 10, 15, 20} Or Multiple = 20 Factors = {1, 2, 4, 5, 10, 20}
10th Jun 2021, 11:59 PM
ChaoticDawg
ChaoticDawg - avatar
+ 1
If(n%5==0){cout<<"beep"<<endl} is this correct
11th Jun 2021, 12:15 AM
Ricky Mills
Ricky Mills - avatar
+ 1
Oh, are you doing the C++ countdown end of module project/ code coach? If so you need to cin the given number and loop counting it down, outputing the number, then checking if the number is a multiple of 5 (like your code does), and output "Beep" if true.
11th Jun 2021, 12:33 AM
ChaoticDawg
ChaoticDawg - avatar