TOJ-1203 Factoring Large Numbers

Source: Internet
Author: User

One of the central idea behind much cryptography are that factoring large numbers are computationally intensive. In this context one might use a, digit number, is a product of one of the digit prime numbers. Even with the fastest projected computers this factorization would take hundreds of years.

You don't have those computers available and if you're clever you can still factor fairly large numbers.


Input

The input would be a sequence of an integer values, one per line, and terminated by a negative number. The numbers would fit in GCC ' s long long int datatype.


Output

Each positive number from the input must is factored and all factors (other than 1) is printed out. The factors must is printed in ascending order with 4 leading spaces preceding a left justified number, and followed by a Single blank line.


Sample Input

9012345678911899132545313912745267386521023-1


Sample Output

    2    3    3    5    1234567891    3    3    179    271    1381    2423    30971    411522630413



Source: Waterloo Local Contest Sep, 1996

Decomposition of the formula.

#include <stdio.h>intMain () {Long LongI,n;  while(~SCANF ("%lld", &n) && n>=0){          for(i=2; N>1;){              if(n%i = =0) {printf ("%lld\n", i); N/=i; }              Else{i++; if(i*i>N) {printf ("%lld\n", N);  Break; }}} printf ("\ n"); }      return 0; }  

TOJ-1203 Factoring Large Numbers

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.