Question: Write a JavaScript function factor(), which takes indefinite number of parametersand returns nothing. You can assume there are at least two parameters, and all the

Write a JavaScript function factor(), which takes indefinite number of parametersand returns nothing.

You can assume there are at least two parameters, and

all the parameters are positive whole numbers. (do not need validation)

Refer to the sample runs below.

(1) if the production of all the parameters before the last one is equal to the last parameter,

you display they are complete facotors of the last parameter. e.g.,

factor(2,3,6);

display:

========== Factors ==========

2, 3 are complete factors of 6.

(2) If some number(s) before the last one is(are) factor(s) of the last parameter and others are not,

you display them correspondingly. E.g.,

factor(2,3,4,9);

display:

========== Factors ==========

3 is(are) partial factor(s) of 9.

2, 4 is(are) not factor(s) of 9.

(3) if all the parameters before the last parameter are not factors of the last parameter,

you display those parameters are not factor(s) of the last parameter. e.g.,

factor(2,3,4,5);

========== Factors ==========

2, 3, 4 is(are) not factor(s) of 5.

Sample runs:

Test your function using the following statements and and include them in your submission.

factor(2,3)

factor(2,3,6);

factor(2,3,4,9);

factor(2,3,4,6,12);

factor(2,3,4,5);

output:

========== Factors ==========

2 is(are) not factor(s) of 3.

========== Factors ==========

2, 3 are complete factors of 6.

========== Factors ==========

3 is(are) partial factor(s) of 9.

2, 4 is(are) not factor(s) of 9.

========== Factors ==========

2, 3, 4, 6 is(are) partial factor(s) of 12.

========== Factors ==========

2, 3, 4 is(are) not factor(s) of 5.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!