My opinion on the algorithm [number theory Tour] Pollard Rho factor decomposition

Source: Internet
Author: User

Algorithm code:

#include"stdio.h"#include"conio.h"Main () {intN,i; printf ("\nplease input a number:\n"); scanf ("%d",&N); printf ("%d=", N);  for(i=2; i<=n;i++)     while(n!=i) {if(n%i==0) {printf ("%d*", i); N=n/i; }      Else         Break; } printf ("%d", n);}

Correctness of the algorithm:

Although we test I are not guaranteed to be prime, but the output of I must be prime. This is because the qualitative factor of any number is smaller than itself, after testing the smaller number, such as assuming n%i (i==4) ==0 into the output link, but in fact i=2 cycle has been done, at this time n%4 can not be equal to 0. Try it a few more times and you'll understand.

My opinion on the algorithm [number theory Tour] Pollard Rho factor decomposition

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.