Programming n this problem, the function multiplesinRangeia.bc) has 3 parameters
ID: 3587671 • Letter: P
Question
Programming n this problem, the function multiplesinRangeia.bc) has 3 parameters. The parameters must be integers and b must be larger than a. This function will rint out the numbers between a and b Onclusivel, that are divisible by c For example nuttiplesInRange(1,18,3) would output For this fret o danumber in that 'ange must be outputted, use the consolekgOfuction Console og works lke ale n exceptpints the values to the console nstend of printing hom to , new browser menu Return is not used in this function because the function must print multiple values. When a return statement occurs in a function, the function ends, therefore only to return a single value, where this function needs us to print all the necessary values in the range YOUR ANSWER Draft saved 02.30pm Original code JavaScript (Nodes) e Conplete the funetion below :function multiples!naangela, b, e) { console.logta cbseExplanation / Answer
Hi,
This is pretty simple using loops, since language not specified i am writing a general function, you can use it in any code,
function multiplesInRange(a,b,c ) {
var count=0; //initializing count variable
var i;
if(b<a) //error case
return 0;
for (i = a; i <=b; i++) { //looping from a to b inclusive
if(i%c==0) //if c divides the number
document.write(i)//printing the number
}
}
Thumbs up if this was helpful, otherwise let me know in comments
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.