Sum of 2002 levels

Source: Internet
Author: User
Title Description Description

Known: sn= 1+1/2+1/3+ ... +1/n. Obviously for any one integer k, when n is large enough, SN is greater than K.
An integer k (1<=k<=15) is given, which requires the calculation of a minimum n, which makes the sn>k.

Enter a description input Description

Keyboard input K

Outputs description output Description

Screen Output n

Sample input to sample

1

Sample output sample outputs

2

Data size & Hint

Exercises

Simulation.

Each time the cumulative 1 is divided by the value of n until the value is greater than S.

var i,k,n:longint;

S:real;

Begin

READLN (k);

While S<=k do

Begin

Inc (N);

s:=s+1/n

End

Writeln (N)

End.

Sum of 2002 levels

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.