1/1! + 1/2! + 1/3! +... + 1/N !...... Deep feelings

Source: Internet
Author: User

This is an interesting one. I just learned it when I went to school.C LanguageWhen I started my first lesson on data structure, the teacher gave me the following question:
Use programming: 1/1! + 1/2! + 1/3! +... + 1/n!
Then I thought, isn't that easy!

Float S = 0 ;
For ( Int I = 1 ; I <= 34 ; I ++ )
{
Int K = 1 ;
For ( Int J = 1 ; J <= I; j ++ )
K * = J;
S + = 1 / K;
}

When I was proud, the teacher wrote his on the blackboard. Code : Float S = 1 ;
For ( Int I = 2 , J = 1 ; I <= 10 ; I ++ )
{
J=I*J;
S+ =1/J;
}

Every day, every day. At that time, I was very ashamed. He has a loop, and I have two loops. He has done a lot of things repeatedly. From which point I realized that programming has many mysteries and many skills that I need to learn. From this, I figured out thatProgramDo the same job as little as possible.

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.