Solving Subset-Product with INTEGER FACTORIZATION (I'm seeing some similarities to both problems. It would be cool if Factorization was NP-complete!)
import itertools
import operator
from operator import mul
from functools import reduce
from itertools import combinations
import ast

# Solves decision problem that excludes 2_products of (target, 1)
# Only solves positive cases
# Non-repeating integers only


while True:

# Takes input array for Subset-Product

 subset_array = input("Please enter a dictionary: ")
 subset_array = ast.literal_eval(subset_array)


# Takes in target to factor. The loop will find all factors
# The factors will be saved in a list for the next loop.

 target = int(input('enter target to factor, to find K_products: '))

 factors = [];
 for j in range(2, target):
     if target % j == 0:
         factors.append(j)

# Using combinations for subset-product. It will find all combinations
# out of the list factors. A simple "isSubset" comparison will be done
# to decide if the subset of factors exist in subset_array.
# If so a True is returned. 


 for j in range(0, len(factors)):
  for jj in combinations(factors, j):
   if len(jj) > 0:  
    if reduce(mul,jj) == target:
      true = str(set(jj) <= set(subset_array))
      if true == str('True'): 
       print(set(jj) <= set(subset_array), jj)

Output

Please enter a dictionary: 5,4,3,2,1
enter target to factor, to find K_products: 120
True (2, 3, 4, 5)
πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/Hope1995x
πŸ“…︎ Mar 17 2020
🚨︎ report
What would be the best thing to do if I, a college mathematician, solved large integer factorization problem in an efficient time.

I thought of several options:

  1. Publish
  2. Run to the Government
  3. Open a private firm offering decryption services with a stunning success. Are there other options?
πŸ‘︎ 4
πŸ’¬︎
πŸ‘€︎ u/UltraB0b
πŸ“…︎ May 26 2017
🚨︎ report
The Quadratic Sieve algorithm for Integer Factorization

My writeup on the Quadratic Sieve algorithm - https://risencrypto.github.io/QuadraticSieve/

Many of the popular Asymmetric Cryptography algorithms are based on the difficulty of factoring very large semiprimes (semi prime is a non-prime which factors into exactly 2 primes). Large means 300 digit numbers or 600 digit numbers.

It's easy to multiply 2 large primes & find the product. But reversing it to find the 2 numbers which were multiplied to get the product is a very, very hard problem.

So in the first place, for implementing the algorithm, you have to find very large primes (which are usually found using the Miller-Rabin algorithm).

Studying the reverse (factoring large semiprimes) is important for

  • for attackers trying to attack it

  • you need to know how large a prime can be factored in finite time with current computing power so that you know how large a number you should use to prevent that.

The Quadratic Sieve is the second fastest algorithm for factoring large semiprimes. It’s the fastest for factoring ones which are lesser than 100 digits long.

πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/HenryDaHorse
πŸ“…︎ Aug 17 2021
🚨︎ report
Integer Factorization

Hey everyone, I've created this program to try to solve Integer factorization problem, but when i run the script it loads for the entire time. Would this work on better server grade computers? Here is the script:

publickey = input("Enter the public key: ")

a = int(publickey)

flag = False

n = 0

while n < a:

while flag == False:

for b in range(2,a):

prime1 = a/b

p = 0

for i in range(2,a):

if prime1 % i == 0 and prime1 != p:

flag = True

if flag == True:

for c in range(2,a):

sum = prime1*c

prime1 = p

if sum == a:

print (prime1)

print (c)

n = n+1

I've ran it without the first while loop and was able to get the first two primes it gets, but then it stopped cause flag was true.

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/Big_bag42069
πŸ“…︎ Jul 05 2021
🚨︎ report
The Quadratic Sieve algorithm for Integer Factorization risencrypto.github.io/Qua…
πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/HenryDaHorse
πŸ“…︎ Aug 15 2021
🚨︎ report
Prime Factorization of Integers In a Text File

I have a text file with a million integers, each in a new line. For each of these integers, I need to resolve them into their prime factors and exponents. For instance, an integer like 100 should be resolved to 2^2x5^2. I have written the following (poor) code in Java but it just doesn't work as it should. That is, it only reads the first line of the text file and even then, if that integer is an odd number, it doesn't output anything. If it is an even number it only outputs 2^(exponent count). For instance, 100,000,000 returns 2^8. That's it, which is obviously incorrect. Please help. You can write your own version in a language you are familiar with.

package PrimeFact;

import java.math.*;

import java.io.File;

import java.io.FileNotFoundException;

import java.util.Scanner;

public class PrimeFact{

public static void main(String[] args) throws FileNotFoundException {

try {

File myObj = new File("C:\\Users\\mugah\\Desktop\\hello.txt");

Scanner myReader = new Scanner(myObj);

while (myReader.hasNextLine()) {

String data = myReader.nextLine();

BigInteger number = new BigInteger(data);

int i = 2;

BigInteger newi = BigInteger.valueOf(i);

for (i = 2;

(newi.compareTo(number) == 0 || newi.compareTo(number) == -1); i++) {

int count = 0;

while (number.mod(newi).compareTo(BigInteger.ZERO) == 0) {

number = number.divide(newi);

count++;

}

if (count == 0) continue;

System.out.print(i + "**" + count + ".");

}

}

myReader.close();

} catch (FileNotFoundException e) {

System.out.println("An error occurred.");

e.printStackTrace();

}

}

}

Thank you. That will be all.

πŸ‘︎ 3
πŸ’¬︎
πŸ“…︎ Dec 20 2020
🚨︎ report
RSA-240 factored β€” new integer factorization record lists.gforge.inria.fr/pip…
πŸ‘︎ 366
πŸ’¬︎
πŸ‘€︎ u/ixfd64
πŸ“…︎ Dec 02 2019
🚨︎ report
Another integer factorization record: RSA-250 mersenneforum.org/showthr…
πŸ‘︎ 46
πŸ’¬︎
πŸ‘€︎ u/ixfd64
πŸ“…︎ Feb 28 2020
🚨︎ report
Another integer factorization record: RSA-250 mersenneforum.org/showthr…
πŸ‘︎ 38
πŸ’¬︎
πŸ‘€︎ u/ixfd64
πŸ“…︎ Feb 28 2020
🚨︎ report
Integer factorization using regex (with backreferences) yurichev.com/news/2020062…
πŸ‘︎ 9
πŸ’¬︎
πŸ‘€︎ u/ArthurStr0ng
πŸ“…︎ Jun 24 2020
🚨︎ report
RSA-240 factored β€” new integer factorization record lists.gforge.inria.fr/pip…
πŸ‘︎ 61
πŸ’¬︎
πŸ‘€︎ u/ixfd64
πŸ“…︎ Dec 02 2019
🚨︎ report
Integer factorization using regex (with backreferences) yurichev.com/news/2020062…
πŸ‘︎ 5
πŸ’¬︎
πŸ‘€︎ u/ArthurStr0ng
πŸ“…︎ Jun 24 2020
🚨︎ report
How many integer factorization algorithm do you know?

I'm solving a challenge where I should factorize this RSA modulus: 85737914105567266183100788624484418711280900241044365214663691835635317826543443063143976809608344194249114776605426568498270124795493303624975384400447493193170052053344543935668697522988211158557528827577595697212680348719528920982604561256941228129998021815001150237085975555109727173275316438372558567696717284749745152486472846839830811719245253674573696720087659513136981252971213162359513063642183176613569345118049896820749640462010343460030817035187074140156234851173597857913872280840739710132748356190524174899883301213563153677520287623128053160275215134435871533438627283575702919158004068417720519960443201925994224772997949913048228261

I tried a lot of different factorization algorithms like Wiener, Fermat, Pollard, etc...

Do you know other ones? What do you suggest to factorize it?

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/Cricco95
πŸ“…︎ Oct 24 2019
🚨︎ report
Why Is Integer Factorization Hard? crasmaru.com/post_3.jsp
πŸ‘︎ 30
πŸ’¬︎
πŸ‘€︎ u/almaya
πŸ“…︎ Oct 30 2018
🚨︎ report
SOURCE CODE FOR INTEGER FACTORIZATION. This program can factor integers of any arbitrary precision. So public key encryption is null and void as it attacks the basic premise that very large integers cannot be factored in reasonable amounts of time β€’ r/netsec reddit.com/r/netsec/comme…
πŸ‘︎ 65
πŸ’¬︎
πŸ‘€︎ u/breadfag
πŸ“…︎ Jul 26 2017
🚨︎ report
Looking for a quote on integer factorization

Apologies if this is the wrong place to post this. I'm running a workshop on public key cryptography soon and I'd like to be able to show a quote I saw a few months ago. It was a quote by someone in the 1800's (I think), basically saying:

> (some big number) is the product of (smaller number) and (smaller number), but I believe that only knowing the product no man would ever be able to know the two factors used in producing it

I haven't for the life of me been able to find this quote so I would appreciate any help. Thanks!

Edit - I found it! It's by William Stanley Jevons and the quote is as follows:

> Can the reader say what two numbers multiplied together will produce the number 8616460799? I think it unlikely that anyone but myself will ever know.

πŸ‘︎ 22
πŸ’¬︎
πŸ‘€︎ u/jamesk727
πŸ“…︎ Oct 29 2016
🚨︎ report
Is there a harder alternative to integer factorization for the purposes of cryptography?

I'm thinking of the (unlikely) case where P=NP is found. Since factorization is known to be in NP, this would likely lead to RSA being considered broken.

Is there a harder alternative that could be used in place of current systems for the purposes of public-key cryptography; or does the fact that if a problem can be verified in P then it is in NP break everything?

πŸ‘︎ 33
πŸ’¬︎
πŸ‘€︎ u/FlightOfStairs
πŸ“…︎ Apr 26 2012
🚨︎ report
My journey to finding a faster algorithm for integer factorization. (Long post)

Hi guys I am a senior in high school and I got into math a few years ago. I was fascinated in finding huge prime numbers, and I ran a computer algorithm to find them ( the Lucas-lehmer-Riesel test). Well, I wanted to find out how it works so I taught myself modular arithmetic, which I'm pretty good at.

So I was messing around with different polynomial equations one day trying to find patterns in prime numbers, and I actually managed to independently discover Fermat's factoring method by looking at functions of the form x^2 -c^2 for constant c and finding a pattern in their factors. So I found an algorithm to put numbers in this form, and that is how I independently discovered Fermat's factoring method. From then on I became interested in factoring algorithms after I discovered no fast ones exist for general numbers.

As much as I tried, I could not get myself to understand the newer factoring algorthms- quadratic sieve, number field sieve, much to my frustration. So I sought out my own methods that high school me could understand.

I came across the method I have been researching by looking at residues of fermat's little theorem. My thought was that if fermat's little theorem could determine a number to be prime, it could determine the factors as well, and the factors were hidden somewhere in the residue. So I whipped up a computer program to output a ton of residues and search for patterns but I was of course wrong. However I did spot patterns.

I noticed that factorials "magically" revealed factors of numbers when they would pop up randomly in the residues they would factor the number.

If n! is between the factors of a number then it would factor the number with a gcd algorithm. The size of the numbers to factor would be about 300 digits long. Even more interesting, the gcd algorithm tells us if n! is larger or smaller than the factors if it doesn't find factors. So a logarithmic run time binary search can be used. This along with the fact that gcd () has a run time of log(x) means my algorithm has a log^2 (x) run time assuming we can find n! mod p efficiently. p is the number to be factored which is around 300 digits or more so it can compete with cuttent factoring algorithms. The n! Mod p is the first step in computing gcd (n !, p) using the extended Euclidian, and also the hardest step. Then all other steps will be trivial as n! mod p < p, and so the size of both inputs is no larger than p.

The best algorithms out there for finding n! Mod p do

... keep reading on reddit ➑

πŸ‘︎ 39
πŸ’¬︎
πŸ‘€︎ u/wcb98
πŸ“…︎ Apr 21 2016
🚨︎ report
Integer factorization reddit.com/r/MathJokes/co…
πŸ‘︎ 8
πŸ’¬︎
πŸ‘€︎ u/ixfd64
πŸ“…︎ Apr 22 2019
🚨︎ report
Integers uniquely determined by their prime factorization...

Is there any way to make the primes a basis for a vector space (the integers)? I've been thinking about this all day, but no mater how I look at it, it falls apart somewhere. Addition would be defined as multiplication, and scalar multiplication would have to be exponentiation, but then it's no longer closed if the scalar is negative or non-integer. Is there anything I can do with this idea in some other section of math that doesn't care about it not being closed under scalar multiplication? I'm just really fond of the idea of for example expressing 54 as <1,3,0,0,....> or a vector one unit in the '2' direction and three units in the '3' direction... and maybe playing around with them from there...

Note: I'm in a linear algebra class at a community college, please try not to go too far over my head, thanks! Better yet, just tell me this is ridiculous so I can go back to actual assigned homework.

πŸ‘︎ 50
πŸ’¬︎
πŸ‘€︎ u/cognificent
πŸ“…︎ Jun 14 2010
🚨︎ report
Does anyone have a better way to solve this quant problem? *A* The number of distinct positive integer factors of 96 vs. *B* the number of distinct positive integer factors of 72

The answer is β€œC” The two quantities are equal. Is there any way to solve it than to think through and list out all the factors the #s can be divided by?

I find that to be time consuming and easy to miss a factor

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/souper_soups
πŸ“…︎ Nov 11 2020
🚨︎ report
I made an integer factorization algorithm. How efficient is it?

https://repl.it/@ddotquantum/Integer-factorization

Edit: It returns the prime factorization of x, not the factors of x.

πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/ddotquantum
πŸ“…︎ Jul 12 2018
🚨︎ report
Show that for a positive integer n and a prime p, the largest power of p occurring in the prime factorization of n! is [n/p] + [n/(p^2)] + [n/(p^3)] + ...

x is a real number, where [x] is the largest integer m with m ≀ x.

We know n! = 1 * 2 * 3 .... n

and so,

(p, 2p, 3p, ...) => (n/p)

(p^2 , 2p^2 , ...) => (n/(p^2 ))

(p^3 , 2p^3 , ...) => (n/(p^3 ))

I don't know where to go from here.

πŸ‘︎ 3
πŸ’¬︎
πŸ‘€︎ u/Eksanol
πŸ“…︎ Sep 25 2017
🚨︎ report
Is Number Field Sieve still the current state-of-the-art integer factorization method?
πŸ‘︎ 2
πŸ’¬︎
πŸ‘€︎ u/sp31415926535
πŸ“…︎ Jun 07 2017
🚨︎ report

Please note that this site uses cookies to personalise content and adverts, to provide social media features, and to analyse web traffic. Click here for more information.