codevs1792 decomposition factorization

Source: Internet
Author: User

Title Description Description

Write a program that decomposes integer n into the product of a mass factor.

Enter a description Input Description

Enter an integer N

Output description Output Description

Output decomposition factorization. In the form of several prime numbers multiplied, prime numbers must be multiplied from small to large.

Sample input Sample Input

756

Sample output Sample Output

756=2*2*3*3*3*7

Data range and Tips Data Size & Hint

The range is within the longint. Not high precision.

#include <stdio.h>#include<math.h>intPrimeinta) { inti; for(i=2; I<sqrt (a); i++)  if(a%i==0)   return 1; return 0;}intMain () {inti,n,flag=0; scanf ("%d",&N); printf ("%d=", N);  for(i=2; i<=n;i++) {  if(Prime (i))Continue;  while(1)  {   if(n%i==0) {n/=i; if(n!=1) printf ("%d*", i);Elseprintf ("%d", i); }   Else     Break; } } return 0;}

codevs1792 decomposition factorization

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.