C language Function call 02-A positive integer of three digits = the sum of the factorial of the numbers of its members

Source: Internet
Author: User

Function call + Enumeration method
/*
==========================================================
Title: Ask for a three-digit positive integer = The sum of the factorial of the numbers of its members!
such as: 145=1!+4!+5!.
==========================================================
*/
#include <stdio.h>
int J (int n)
{
int t=1,i;
for (i=1;i<=n;i++)
T*=i;
return (t);
}
Main ()
{
int S,i,ge,shi,bai,qian;
for (s=100;s<1000;s++)
{
ge=s%10;
shi=s/10%10;
bai=s/100%10;
if (S==j (GE) +j (shi) +j (bai))
printf ("%d=%d!+%d!+%d!\n", S,bai,shi,ge);
}
}

/*
==========================================================
Comment: First write a function J for factorial, and then use division and remainder to find out "a 1000"
Bit, the number that matches the IF condition is found through the enumeration method.
==========================================================
*/

Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

C language Function call 02-A positive integer of three digits = the sum of the factorial of the numbers of its members

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.