factorization

What is the fastest way to find divisor of any bigInteger in c# [closed]

余生长醉 提交于 2021-02-08 12:09:07
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . Improve this question I want to run something like below code so that i would be able to find a divisor for numbers of ~30-40 length without having to check millions of possibilities even up to their square root. What is the fastest possible solution to find a legitimate non

What is the fastest way to find divisor of any bigInteger in c# [closed]

回眸只為那壹抹淺笑 提交于 2021-02-08 12:06:59
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 4 years ago . Improve this question I want to run something like below code so that i would be able to find a divisor for numbers of ~30-40 length without having to check millions of possibilities even up to their square root. What is the fastest possible solution to find a legitimate non

Factor a quadratic polynomial in Python

大憨熊 提交于 2021-02-05 06:57:26
问题 Since factoring a quadratic equation in my head just happens, and has done that since I learned it - how would I go about starting to write a quadratic factorer in Python? 回答1: Improving Keiths's answer: Start with a polynomial P(x) = a*x^2 + b*x + c . Use the quadratic formula (or another another method of your choice) to find the roots r1 and r2 to P(x) = 0 . You can now factor P(x) as a*(x-r1)(x-r2) . If your factor (3x - 4)(x - 9) the solution will be 3*(x - 4/3)(x - 9). You might want to

Algorithm: Factorize a integer X to get as many distinct positive integers(Y1…Yk) as possible so that (Y1+1)(Y2+1)…(Yk+1) = X

99封情书 提交于 2021-01-28 13:00:33
问题 I recently met a algorithm question in open.kattis.com. The question's link is https://open.kattis.com/problems/listgame2. Basically, it is a question ask the players to factorize a integer X (10^3 <= X <= 10^15) to get as many distinct positive integers (Y 1 ,...,Y k ) as possible such that (Y 1 +1)(Y 2 +1)⋯(Y k +1) = X. I already came up with a solution using Python3, which does pass several test cases but failed one of them:MyStatus My code is: def minFactor(n, start): maxFactor = round(n*

2-3-5-7 wheel factorization seems to skip prime number 331

家住魔仙堡 提交于 2020-01-01 15:07:13
问题 When following the procedure on wikipedia for wheel factorization, I seem to have stumbled into a problem where the prime number 331 is treated as a composite number if I try to build a 2-3-5-7 wheel. With 2-3-5-7 wheel, 2*3*5*7=210. So I setup a circle with 210 slots and go through steps 1-7 without any issues. Then I get to step 8 and strike off the spokes of all multiples of prime numbers, I eventually strike off the spoke rooted at 121, which is a multiple of 11, which is a prime. For the

Efficiently getting all divisors of a given number

给你一囗甜甜゛ 提交于 2019-12-28 04:46:26
问题 According to this post, we can get all divisors of a number through the following codes. for (int i = 1; i <= num; ++i){ if (num % i == 0) cout << i << endl; } For example, the divisors of number 24 are 1 2 3 4 6 8 12 24 . After searching some related posts, I did not find any good solutions. Is there any efficient way to accomplish this? My solution: Find all prime factors of the given number through this solution. Get all possible combinations of those prime factors. However, it doesn't

finding power of a number

…衆ロ難τιáo~ 提交于 2019-12-25 04:24:56
问题 I have a very big number which is a product of several small primes. I know the number and also I know the prime factors but I don't know their powers. for example: (2^a)x(3^b)x(5^c)x(7^d)x(11^e)x .. = 2310 Now I want to recover the exponents in a very fast and efficient manner. I want to implement it in an FPGA. Regards, 回答1: The issue is that you are doing a linear search for the right power when you should be doing a binary search. Below is an example showing how to the case where the

How to define the partitions (factorizations w.r.t. concatenation) of a sequence as a lazy sequence of lazy sequences in Clojure

倾然丶 夕夏残阳落幕 提交于 2019-12-25 01:39:56
问题 I am new to Clojure and I want to define a function pt taking as arguments a number n and a sequence s and returning all the partitions of s in n parts, i.e. its factorizations with respect to n -concatenation. for example (pt 3 [0 1 2]) should produce: (([] [] [0 1 2]) ([] [0] [1 2]) ([] [0 1] [2]) ([] [0 1 2] []) ([0] [] [1 2]) ([0] [1] [2]) ([0] [1 2] []) ([0 1] [] [2]) ([0 1] [2] []) ([0 1 2] [] [])) with the order being unimportant. Specifically, I want the result to be a lazy sequence