Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases Organizing Information Digital And Information Literacy

Authors: Greg Roza

1st Edition

1448805929, 978-1448805921

More Books

Students also viewed these Databases questions