Question 84: Decomposition factor

Source: Internet
Author: User


Print? # Include <stdio. h>
 
Int main ()
{
Int I;
Int j = 0;
Int begin_num;
Int num;
Int mark;
Int count [100];
Int collect [100] = {0 };
 
Printf ("please enter a number :");
Scanf ("% d", & num );

Begin_num = num; // use begin_num to keep num. The following Operation changes the value of num.
For (I = 1; 2 * I-1 <num; I ++) // use an odd number, an even number is omitted
{
Mark = 2 * I-1; // odd
If (mark = 1) // increase by 2 because 2 is an even number of prime numbers.
{
Mark = 2;
}
 
If (num % mark = 0)
{
Count [j] = mark; // records the number of times a mark is divided.
While (num % mark = 0)
{
Num = num/mark;
Collect [j] ++; // records the number of times a mark is divided.
}
J ++;
}
}
 
For (I = 0; I <j; I ++)
{
If (I = 0) // limit printing once
{
Printf ("% d =", begin_num );
}
Printf ("% d (% d)", count [I], collect [I]);
If (I = J-1) // last line feed
{
Printf ("\ n ");
}
}
}

# Include <stdio. h>

Int main ()
{
Int I;
Int j = 0;
Int begin_num;
Int num;
Int mark;
Int count [100];
Int collect [100] = {0 };

Printf ("please enter a number :");
Scanf ("% d", & num );

Begin_num = num; // use begin_num to keep num. The following Operation changes the value of num.
For (I = 1; 2 * I-1 <num; I ++) // use an odd number, an even number is omitted
{
Mark = 2 * I-1; // odd
If (mark = 1) // increase by 2 because 2 is an even number of prime numbers.
{
Mark = 2;
}

If (num % mark = 0)
{
Count [j] = mark; // records the number of times a mark is divided.
While (num % mark = 0)
{
Num = num/mark;
Collect [j] ++; // records the number of times a mark is divided.
}
J ++;
}
}

For (I = 0; I <j; I ++)
{
If (I = 0) // limit printing once
{
Printf ("% d =", begin_num );
}
Printf ("% d (% d)", count [I], collect [I]);
If (I = J-1) // last line feed
{
Printf ("\ n ");
}
}
}



Related Article

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.