24. Collecting all prime factors of a given number A prime number is a number divisible by itself and 1…