Pascal uses a high precision method to find the exact value of s 1 2 3 n

Updated on technology 2024-04-10
4 answers
  1. Anonymous users2024-02-07

    Second floor. Are you ready to add from 1 to n one by one?

    Landlord. Use the formula s=n*(n+1).

    A high-precision multiplication is OK.

  2. Anonymous users2024-02-06

    I don't know, how tall do you want to be?

    If you want 100 bits, you must have arrays.

  3. Anonymous users2024-02-05

    Let's start with a few ways to do power operations:

    can be passed by symbols"** Realized, but limited in scope, approximately around 2 31 or so.

    This can be done by exp(x*ln(y)) to calculate the power of y to the xth power, but the result is a real number.

    And the answer on the first floor is obviously too complicated.

    **As follows: Method 1:

    varn,i:integer;

    varans:longint;

    beginans:=1;

    fori:=1ton

    doans:=ans+i**i;

    writeln(ans);

    end.This method is simple, but the scope is limited, n maximum is about 9 method two: var

    n,i:integer;

    varans:extended;

    beginans:=1;

    fori:=1ton

    doans:=ans+exp(i*ln(i));

    writeln(ans);

    end.The range of this method has been expanded, but the output number is the number of the real Huaishan grip expressed by the scientific calculation and only attack number method.

    Method 3: Using the combination of high-precision addition, high-precision multiplication and character lead qingfu string, the algorithm is very complex, and it can be calculated to infinity in theory, but the processing power of the computer is limited, so it will not exceed a limit in practice. (**Overly complicated).

  4. Anonymous users2024-02-04

    Calculation of factorials.

    Problem description. Enter an integer n(1<=n<=1000) and enter n!The exact value of .

    Analysis: When n is larger, n!is a very large number, and both the real and integer types of the pascal cannot be stored, all of which are calculated with high precision.

    The case of this problem is more peculiar, and we can put n!Look at it as (n-1)!*n, so that one of the two numbers involved in multiplication is a high-precision number (n-1)!, and the other is a regular integer n

    Let's look at how to get n!e.g. 12! =12*11!=12*39916800, take the following examples to illustrate the calculation process:

    Array a(2) multiplies each element in a by the multiplier (here 12) when performing the calculation, and the result is stored in the current bit, and the above array a is multiplied by 12, and the intermediate result is: subscript k

    The array a(3) will process the carry after each product operation, as in the example above, a[3] will carry 9 to a[4], a[3]=6, a[4]=81, and a[4] is carrying 8 to a[5], a[4]=1, a[5]=20, a[5] to a[6] carry 2, a[5]=0, a[6]=110, a[6] to a[7] to carry 11, a[6]=0, a[7]=119, a[7] to a[8]. Carry 11, after carrying, a[7]=9, a[8]=47, a[8] to a[9] carry 4, after carrying[8]=7, a[9]=4, a[9] does not have to carry to a[10], until some carry processing is completed. After being processed by carrying, the data stored in the a-array is as follows: subscript k

    Array A: The number stored in array A is 12!=479001600, which is the same as the result of our manual calculation.

    varn,i,j,k,x,q:word;

    a:array[1..3000]

    ofword;

    beginwrite('n=')readln(n);

    fori:=1to

    doa[i]:=0;

    k:=1;a[1]:=1;

    fori:=2ton

    dobegin

    forj:=1tok

    doa[j]:=a[j]*i;

    q:=0;for

    j:=1tokdo

    beginx:=a[j]+q;

    a[j]:=xmod

    q:=xdiv

    end;while

    q>0)

    dobegin

    k:=k+1;

    a[k]:=qmod

    q:=qdiv

    end;end;

    fori:=k

    downto

    dowrite(a[i]);

    writeln;

    writeln('k=',k);

    end.

Related questions
5 answers2024-04-10

Find the "Deep Hole Forum", which specializes in discussing deep hole processing and other related technical exchanges. >>>More

6 answers2024-04-10

Printers are currently up to 9600dpi

Laser machine normal 600dpi >>>More

4 answers2024-04-10

The Pascal compilation system is a system software. Pascal is the first structured programming language with rigorous syntax, clear hierarchy, easy to write and readable programs. Pascal language is widely used in various software, and the program is divided into name (self-proposed after program), setting (defined after var), start (begin), program (body), read (read read ln), and end (end), with strong structural hierarchy, rigorous and tight. >>>More

6 answers2024-04-10

The top surface of the steel structure is not only the installation of lamps and lanterns, the finished tube chandelier is generally equipped with a metal installation base, and the wires should also be installed and laid, and the junction box is preset at the position of the lamps and lanterns while laying the wire pipe on the top surface, and the lamps and lanterns can be installed on it, if the lamps and lanterns are very heavy, such as the lamps and lanterns with positive flowers, or mixed lights, their lampshades are very large, and it is recommended to install them directly on the metal beams.