Fermat’s algorithm was based on the fact that any odd number can be expressed as the difference between two squares. When the factors are near the root of the number, they can be calculated easily and quickly. The method isn’t feasible when factors are truly random and hence far apart.

Source: *Researcher uses 379-year-old algorithm to crack crypto keys found in the wild | Ars Technica*