26. Prime Factors

Difficulty: 

Given a positive integer and a non-empty list of prime numbers, determine if the number only consists of those prime factors. For example, if the list of prime numbers is [2, 3, 5, 7], the number 140 = 2^2 * 5 * 7 has the right prime factors, while 26 = 2 * 13 does not.

Input:

primeFactors(140, [
  2,
  3,
  5,
  7
]);

Output:

true

Time Limit:

1000 (ms)

Hint (hover to see):

  • Hint #1



Results

ProblemsAcceptedWrongTimed OutError
170000

Input:

Expected Output:

Output: