

def prime_factors(number, n=2, factors=None):
    if factors is None:
        factors = []
    for num in range(n, number):
        if (number % num) == 0:
            factors.append(num)
            return prime_factors(number // num, num, factors)
    else:
        return factors



def prime_factors(number):
        num = 2
        factors = []
        while num <= number:
            if (number % num) == 0:
                number /= num
                factors.append(num)
            else:
                num += 1

        return factors

Change if condition to while with reformat
Change if condition to while with reformat

  
  
- def prime_factors(number, n=2, factors=None):
-     if factors is None:
+ def prime_factors(number):
+         num = 2
          factors = []
-     for num in range(n, number):
+         while num <= number:
-         if (number % num) == 0:
+             if (number % num) == 0:
+                 number /= num
-             factors.append(num)
+                 factors.append(num)
-             return prime_factors(number // num, num, factors)
-     else:
+             else:
+                 num += 1
+ 
          return factors
  
Change if condition to while with reformat
## Code Before:


def prime_factors(number, n=2, factors=None):
    if factors is None:
        factors = []
    for num in range(n, number):
        if (number % num) == 0:
            factors.append(num)
            return prime_factors(number // num, num, factors)
    else:
        return factors

## Instruction:
Change if condition to while with reformat
## Code After:


def prime_factors(number):
        num = 2
        factors = []
        while num <= number:
            if (number % num) == 0:
                number /= num
                factors.append(num)
            else:
                num += 1

        return factors
