The Fermat method is considered to be the best for factorization of numbers N=p×q in case of close p and q. Computational complexity of the basic algorithm of the method is determined by the number of check values of X when solving equation Y2=X2‑N, as well as by complexity of the arithmetic operations. To reduce it, it is proposed to consider admissible those of test values X, for which (X2–N)modbb is quadratic residue modulo bb, called basic. Application of basic foundation of module bb makes it possible to decrease the number of check X by the number of times, close to Z=bb/bb*, where bb* is the number of elements of set Т of the roots of equation (Ymodb)2modb=((Xmodb)2–Nmodb)modb, and Z is the acceleration coefficient.It was determined that magnitude Z(N, bb) is affected by the value of residues Nmodp (at p=2, Nmod8 residues are used). The statement of the problem of finding bb with a maximum Z(N, bb) at restrictions for the amount of memory of the computer, where exponents of prime numbers – multipliers bb – are determined, and the method of its solution were proposed.To decrease the number of arithmetic operations with big numbers, it was proposed that instead of them to perform the operations with the values of differences between the nearest values of elements T. Then arithmetic operations of multiplication and addition with big numbers are performed only in rare cases. And if we derive the square root of X2–N only in cases, where the values of (X2–N)modb will be quadratic residues for many foundations of module b, other than bb, the computational complexity of this operation can be neglected.It was established that the proposed modified algorithm of the Fermat method for numbers 21024 ensures a decrease in computational complexity compared to the basic algorithm on average by 107 times, Метод Ферма считается лучшим при факторизации чисел N=p×q в случае близьких p и q. Вычислительная сложность базового алгоритма метода определяется количеством пробных значений Х при решении уравнения Y2=X2‑N, а также сложностью арифметических операций. Для ее снижения предлагается в качестве допустимых рассматривать те из пробных Х, для которых (X2-N)modbb является квадратичным остатком по модулю bb, названного базовым. Применение базового основания модуля bb позволяет уменшить число пробных Х в число раз, близкое к Z=bb/bb*, где bb* – число элементов множества Т корней уравнения (Ymodb)2modb=((Xmodb)2-Nmodb)modb, а Z – коэффициент ускорения.Определено, что на величину Z(N,bb) влияют значения остатков Nmodp (при р=2 используются остатки Nmod8). Предложена постановка задачи поиска bb с максимальным Z(N,bb) при ограничениях на объем памяти ЭВМ, где определяются показатели степеней простых чисел – множителей bb, и способ ее решения.Для уменьшения числа арифметических операций с большими числами предложено вместо таких выполнять операции со значениями разностей между ближайшими значениями элементов Т. Тогда арифметические операции умножения и сложения с большими числами выполняются только в редких случаях. А если квадратный корень из X2-N определять только в случаях, когда значения (X2-N)modb будут квадратичными остатками для многих оснований модуля b, отличных от bb, то вычислительной сложностью этой операции можно пренебречь.Установлено, что тогда предложенный модифицированный алгоритм метода Ферма для чисел 21024 обеспечивает снижение вычислительной сложности по сравнению с базовым алгоритмом в среднем в 107 раз, Метод Ферма вважається кращим при факторизації чисел N=p×q у випадку близьких p і q. Обчислювальна складність базового алгоритму методу визначається кількістю пробних значень Х при вирішенні рівняння Y2=X2‑N, а також складністю арифметичних операцій. Для її зниження запропоновано в якості допустимих розглядати ті з пробних Х, для яких (X2-N)modbb є квадратним залишком по модулю bb, названого базовым. При використанні базової основи модуля bb число пробних Х зменшується в число раз, близьке до Z(N,bb)=bb/bb*, де bb* – число елементів множини Т коренів рівняння (Ymodb)2modb=((Xmodb)2-Nmodb)modb, а Z – коефіцієнт прискорення.Визначено, що на величину Z(N,bb) впливають значения залишків Nmodp (при р=2 використовуються залишки Nmod8). Запропоновано постановку задачі пошуку bb з максимальным Z(N,bb) при обмеженях на обсяг пам’яті ЕОМ, де визначаються показники степенів простих чисел – множників bb, та спосіб її вирішення.Для зменшення числа арифметичних операцій з великими числами попонується замість таких виконувати операції зі значеннями різниць між найближчими значеннями елементів множини Т. Тоді арифметичні операції множення і додавання з великими числами виконуються рідко. А якщо квадратний корінь з X2-N визначати тільки у випадках, коли значення (X2-N)modb будуть квадратними залишками для багатьох різних основ модуля b, то обчислювальною складністю цієї операції можна знехтувати.Встановлено, що тоді запропонований модифікований алгоритм методу Ферма для чисел 21024 забезпечує зниження обчислювальної складності в порівнянні з базовим алгоритмом в середньому в 107 раз