-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfind_smallest_factor.c
34 lines (31 loc) · 1.12 KB
/
find_smallest_factor.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/*
This file is written by Denis Joseph Barrow [email protected] [email protected]
and formula for the smallest factor was found
by his program fundamental https://github.com/djbarrow/fundamental using symbolic regression techniques
It is hoped this program might crack rsa or give new insights into factorisation.
However it might be a corallory of the fermat primality test https://en.wikipedia.org/wiki/Fermat_primality_test
This algorithm is limited to 2^31 on a 31 bit processor and for this requires at least 8GB of ram as it has to get 2^composite-2 as one of the factors into the Euclid GDB Algorithm
*/
#include <stdio.h>
#include <stdarg.h>
#include <stdlib.h>
#include <unistd.h>
#include <math.h>
#include <string.h>
#include <gmp.h>
int main(int argc,char *argv[])
{
int compositei;
mpz_t composite,rop1,rop2,op1,op2;
mpz_init(rop1);
mpz_set_ui(op1,2);
mpz_init(op2);
mpz_init_set_str(composite,argv[1],10);
compositei=atoi(argv[1])-1;
mpz_mul_2exp(rop1,op1,compositei);
mpz_sub_ui(rop1,rop1,2);
mpz_gcd(rop2,composite,rop1);
printf("\n");
mpz_out_str(stdout,10,rop2);
printf("\n");
}