<commit_before>#pollard rho algorithm of integer factorization


def gcd(a,b):
    if a is 0:
        return b
    return gcd(b%a,a)

def pollard_rho(number,x,y):
    d = 1
    while d is 1:
        x = (x**2+1)%number
        for i in range(0,2,1):
            y = (y**2+1)%number
        if x>y:
            z = x-y
        else:
            z=y-x
        d = gcd(z,number)
    return d

x=2
y=2
number = 84923983
factor = pollard_rho(number,x,y)
while factor is number or 1:
    x = x+1
    y = y+1
    pollard_rho(number,x,y)
factor2 = int(number/factor)

print(factor,factor2)<commit_msg>Update pollard_rho_algorithm.py<commit_after>#pollard rho algorithm of integer factorization

import random
import math
from Crypto.PublicKey import RSA

errors = []

def gcd(a,b):
    if a is 0:
        return b
    return gcd(b%a,a)

def pollard_rho(number,x,y):
    try:
        number = int(number)
    except TypeError as n:
        globals()['errors'].append(n)

    d = 1
    while d is 1:
        x = (x**2+1)%number
        for i in range(0,2,1):
            y = (y**2+1)%number
        if x>y:
            z = x-y
        else:
            z=y-x
        d = gcd(z,number)
    return d


def attack(input={},errors = {},results = {}):
    try :
          number = int(input["key"])
    except TypeError as n:
        globals()['errors'].append(n)

    x=2
    y=2
    factor = pollard_rho(number,x,y)
    while factor is number or 1:
        x = x+1
        y = y+1
        factor = pollard_rho(number,x,y)
    factor2 = int(number/factor)
    results["p "]= factor
    results["q "]= factor2
    return {'errors': globals()['errors'],'results':results}
{'fraction_non_alphanumeric': 0.13353474320241693, 'fraction_numerical': 0.025377643504531724, 'mean_word_length': 2.08955223880597, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5095479', 'n_tokens_mistral': 633, 'n_tokens_neox': 611, 'n_words': 157}