代码拉取完成,页面将自动刷新
using System;
using Algorithms.Numeric.GreatestCommonDivisor;
namespace Algorithms.Other;
/// <summary>Implementation of the Pollard's rho algorithm.
/// Algorithm for integer factorization.
/// Wiki: https://en.wikipedia.org/wiki/Pollard's_rho_algorithm.
/// </summary>
public static class PollardsRhoFactorizing
{
public static int Calculate(int number)
{
var x = 2;
var y = 2;
var d = 1;
var p = number;
var i = 0;
var gcd = new BinaryGreatestCommonDivisorFinder();
while (d == 1)
{
x = Fun_g(x, p);
y = Fun_g(Fun_g(y, p), p);
d = gcd.FindGcd(Math.Abs(x - y), p);
i++;
}
return d;
}
private static int Fun_g(int x, int p)
{
return (x * x + 1) % p;
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。