A prime is a positive integer X that has exactly two distinct divisors: 1 and X. The first few prime integers are 2, 3, 5, 7, 11 and 13.
A prime D is called a prime divisor of a positive integer P if there exists a positive integer K such that D * K = P. For example, 2 and 5 are prime divisors of 20.
You are given two positive integers N and M. The goal is to check whether the sets of prime divisors of integers N and M are exactly the same.
For example, given:
- N = 15 and M = 75, the prime divisors are the same: {3, 5};
- N = 10 and M = 30, the prime divisors aren't the same: {2, 5} is not equal to {2, 3, 5};
- N = 9 and M = 5, the prime divisors aren't the same: {3} is not equal to {5}.
Write a function:
function solution(A, B);
that, given two non-empty arrays A and B of Z integers, returns the number of positions K for which the prime divisors of A[K] and B[K] are exactly the same.
For example, given:
A[0] = 15 B[0] = 75 A[1] = 10 B[1] = 30 A[2] = 3 B[2] = 5the function should return 1, because only one pair (15, 75) has the same set of prime divisors.
Write an efficient algorithm for the following assumptions:
- Z is an integer within the range [1..6,000];
- each element of arrays A and B is an integer within the range [1..2,147,483,647].
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
}
function gcd(a, b) {
let small = Math.min(a, b);
let
if (a % b === 0) {
return b;
} else {
return (b, a % b);
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (a % b === 0) {
return b;
} else {
return (b, a % b);
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, small % b);
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.l)
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
}
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i])
}
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
}
}
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
}
}
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[])
}
}
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
}
}
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
}
}
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
}
}
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val)
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
}
}
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a)
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
}
}
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
let
if (val === a)
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
}
}
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a)
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i]))
}
}
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a)
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a)
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= gcd
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd()
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val)
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max())
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.max())
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
[[7, 17, 5, 3], [7, 11, 5, 2]]
RangeError: Maximum call stack size exceeded at check (solution.js:30:15) at check (solution.js:39:16) at check (solution.js:39:16) at check (solution.js:39:16) at check (solution.js:39:16) at check (solution.js:39:16) at check (solution.js:39:16) at check (solution.js:39:16) at check (solution.js:39:16) at check (solution.js:39:16)
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(a, b) {
// let small = Math.min(a, b);
// let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(big, small) {
// let small = Math.min(a, b);
// let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(big, small) {
// let small = Math.min(a, b);
// let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
let small = Math.min(A[i], B[i]);
let big = Math.max(a,b);
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(big, small) {
// let small = Math.min(a, b);
// let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
let small = Math.min(A[i], B[i]);
let big = Math.max(A[i], B[i]);
if(small === big) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(big, small) {
// let small = Math.min(a, b);
// let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
let small = Math.min(A[i], B[i]);
let big = Math.max(A[i], B[i]);
if(small === big) {
count++;
} else {
let div = gcd(small, big);
if (check(small, div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(big, small) {
// let small = Math.min(a, b);
// let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
let small = Math.min(A[i], B[i]);
let big = Math.max(A[i], B[i]);
if(small === big) {
count++;
} else {
let div = gcd(small, big);
if (check(small, div) && check(big, div)) {
count++;
}
}
}
return count;
}
function gcd(big, small) {
// let small = Math.min(a, b);
// let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
[[7, 17, 5, 3], [7, 11, 5, 2]]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
let small = Math.min(A[i], B[i]);
let big = Math.max(A[i], B[i]);
if(small === big) {
count++;
} else {
let div = gcd(small, big);
if (check(small, div) && check(big, div)) {
count++;
}
}
}
return count;
}
function gcd(big, small) {
// let small = Math.min(a, b);
// let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return g(small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
let small = Math.min(A[i], B[i]);
let big = Math.max(A[i], B[i]);
if(small === big) {
count++;
} else {
let div = gcd(small, big);
if (check(small, div) && check(big, div)) {
count++;
}
}
}
return count;
}
function gcd(big, small) {
// let small = Math.min(a, b);
// let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return gcd(small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
[[7, 17, 5, 3], [7, 11, 5, 2]]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(big, small) {
// let small = Math.min(a, b);
// let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return (small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(big, small) {
// let small = Math.min(a, b);
// let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return gcd(small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
[[7, 17, 5, 3], [7, 11, 5, 2]]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return gcd(small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
[[7, 17, 5, 3], [7, 11, 5, 2]]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return gcd(small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return gcd(small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
[[7, 17, 5, 3], [7, 11, 5, 2]]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return gcd(small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return gcd(small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
[[7, 17, 5, 3], [7, 11, 5, 2]]
[[2147483647], [1]]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return gcd(small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return gcd(small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
[[7, 17, 5, 3], [7, 11, 5, 2]]
[[2147483647, 14, 2147483642], [3, 7, 4]]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return gcd(small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
[[7, 17, 5, 3], [7, 11, 5, 2]]
[[2147483647, 14, 2147483644], [3, 7, 4]]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return gcd(small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return gcd(small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
[[7, 17, 5, 3], [7, 11, 5, 2]]
[[2147483647, 14, 2147483640], [3, 7, 10]]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return gcd(small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
[[7, 17, 5, 3], [7, 11, 5, 2]]
[[2147483647, 14, 2147483640], [3, 7, 10]]
// you can write to stdout for debugging purposes, e.g.
// console.log('this is a debug message');
function solution(A, B) {
// write your code in JavaScript (Node.js 8.9.4)
let count = 0;
for (let i = 0; i < A.length; i++) {
if(A[i] === B[i]) {
count++;
} else {
let div = gcd(A[i], B[i]);
if (check(A[i], div) && check(B[i], div)) {
count++;
}
}
}
return count;
}
function gcd(a, b) {
let small = Math.min(a, b);
let big = Math.max(a,b);
if (big % small === 0) {
return small;
} else {
return gcd(small, big % small);
}
}
function check(a, b) {
let val = gcd(a, b);
if (val === a) {
return true;
} else if (val === 1) {
return false;
} else {
a /= val;
val = gcd(a, val);
return check (Math.max(a, val), Math.min(a, val));
}
}
The solution obtained perfect score.