0

Create a for loop that iterates up to 50 while outputting "hello" at multiples of 4, "world" at multiples of 6 and "hello world"

how to do this

20th Aug 2022, 5:51 AM
Mamudu Razik
Mamudu Razik - avatar
1 ответ
+ 3
To check for multiples use the modulo operator %. Modulo calculates the remainder of a division. If the number is an exact multiple then the remainder is zero, and the result of modulo is zero. if (a%b==0) //then a is a multiple of b.
20th Aug 2022, 5:59 AM
Brian
Brian - avatar