  1. CoderByte

## Question

Have the function Division(num1,num2) take both parameters being passed and return the Greatest Common Factor. That is, return the greatest number that evenly goes into both numbers with no remainder. For example: 12 and 16 both are divisible by 1, 2, and 4 so the output should be 4. The range for both parameters will be from 1 to 10^3.

Use the Parameter Testing feature in the box below to test your code with different arguments.

```.css-e69dqy{position:relative;z-index:0;}.css-qq5p7o{padding:var(--chakra-space-5);border-radius:8px;margin-top:var(--chakra-space-8);margin-bottom:var(--chakra-space-8);background:#011627;-webkit-padding-start:0px;padding-inline-start:0px;-webkit-padding-end:0px;padding-inline-end:0px;overflow:hidden;}function Division(num1, num2) {
const max = Math.max(num1, num2);
const min = Math.min(num1, num2);
if (max % min === 0) {
return min;
}

let res = 1;
for (let i = 0; i <= min / 2; i++) {
if (max % i === 0 && min % i === 0) {
res = i;
}
}

return res;