Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program Lab6;
- {$APPTYPE CONSOLE}
- uses
- SysUtils, Math;
- var
- Multiply: double = 1;
- IsPrime: boolean;
- Count: integer;
- i: integer = 1;
- j: integer;
- Number: integer = 3;
- AbsAc: double;
- RelAc: double;
- const
- C: double = 0.660161181584686;
- begin
- Write(' Enter count prime numbers: ');
- Readln(Count);
- while i <= Count do
- begin
- IsPrime := true;
- for j:= 2 to Trunc(sqrt(Number)) do
- if (Number mod j) = 0 then
- IsPrime := false;
- if IsPrime = true then
- begin
- Multiply:= Multiply * (1-(1/IntPower(Number - 1, 2)));
- Inc(i);
- end;
- Inc(Number);
- end;
- AbsAc:= Abs(C - Multiply);
- RelAc:= AbsAc/C*100;
- Writeln(' Const C = ', C:15:15);
- Writeln(' Approximation = ', Multiply:15:15);
- Write(' Absolute accuracy = ', AbsAc:15:15); Writeln(', Relative accuracy = ', RelAc:15:15, '% .');
- Readln;
- end.
Add Comment
Please, Sign In to add comment