# Number of divisions using trial division to factorize the product of two k-digit primes

I'm more of a programmer than a Mathematician so please bear with me if my question is too trivial.

I am looking up RSA specifically the key generation bit. Using Trial division, I know that it would take roughly `(2*(n^0.5))/ln n` divisions to find the factors of n.

However I'd like to represent this in a generalized manner i.e. how many divisions would it take to factorize the product of two k-digit primes ?

Any help would be much appreciated

-

## 1 Answer

I will assume that both primes are approximately $5\times 10^k$. This is in fact the worst-case scenario for trial division. How long trial division will take depends on how exactly you implement it. If you have a table of all primes with up to $5\times 10^k$, then the number of trial divisions will be equal to the number of primes up to $5\times 10^k$, which is $$\pi(5\times 10^k)\approx\frac{5\times 10^k}{\ln 5\times 10^k}=\frac{5\times 10^k}{\ln 5 + k\ln 10}$$ with the approximation following from the prime number theorem. However, if you do not have such a table (which is likely the case if $k$ is large enough for the primes to be used for RSA) then you will need to perform $5\times 10^k$ trial divisions.

-

Thank you that helped :) – Jonny Mar 25 '12 at 12:25
{"extraction_info": {"found_math": true, "script_math_tex": 0, "script_math_asciimath": 0, "math_annotations": 0, "math_alttext": 0, "mathml": 0, "mathjax_tag": 0, "mathjax_inline_tex": 5, "mathjax_display_tex": 1, "mathjax_asciimath": 0, "img_math": 0, "codecogs_latex": 0, "wp_latex": 0, "mimetex.cgi": 0, "/images/math/codecogs": 0, "mathtex.cgi": 0}, "config": {"markdown_headings": true, "markdown_code": true, "boilerplate_config": {"ratio_threshold": 0.18, "absolute_threshold": 10, "end_threshold": 15, "enable": true}, "remove_buttons": true, "remove_image_figures": true, "remove_link_clusters": true, "table_config": {"min_rows": 2, "min_cols": 3, "format": "github"}, "remove_chinese": true, "remove_edit_buttons": true, "extract_latex": true}, "english_confidence": 0.9554336667060852, "perplexity_flag": "head"}