How to resolve the algorithm Averages/Pythagorean means step by step in the ALGOL 68 programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm Averages/Pythagorean means step by step in the ALGOL 68 programming language

Table of Contents

Problem Statement

Compute all three of the Pythagorean means of the set of integers 1 through 10 (inclusive). Show that

A (

x

1

, … ,

x

n

) ≥ G (

x

1

, … ,

x

n

) ≥ H (

x

1

, … ,

x

n

)

{\displaystyle A(x_{1},\ldots ,x_{n})\geq G(x_{1},\ldots ,x_{n})\geq H(x_{1},\ldots ,x_{n})}

for this set of positive integers.

Let's start with the solution:

Step by Step solution about How to resolve the algorithm Averages/Pythagorean means step by step in the ALGOL 68 programming language

Source code in the algol programming language

main: (
  INT count:=0;
  LONG REAL f, sum:=0, prod:=1, resum:=0;

  FORMAT real = $g(0,4)$; # preferred real format #

  FILE fbuf; STRING sbuf; associate(fbuf,sbuf);

  BOOL opts := TRUE;

  FOR i TO argc DO
    IF opts THEN # skip args up to the - token #
      opts := argv(i) NE "-"
    ELSE
      rewind(fbuf); sbuf := argv(i); get(fbuf,f);
      count +:= 1;
      sum +:= f;
      prod *:= f;
      resum +:= 1/f
    FI
  OD;
  printf(($"c: "f(real)l"s: "f(real)l"p: "f(real)l"r: "f(real)l$,count,sum,prod,resum));
  printf(($"Arithmetic mean = "f(real)l$,sum/count));
  printf(($"Geometric mean = "f(real)l$,prod**(1/count)));
  printf(($"Harmonic mean = "f(real)l$,count/resum))
)

  

You may also check:How to resolve the algorithm JortSort step by step in the Swift programming language
You may also check:How to resolve the algorithm Minimum multiple of m where digital sum equals m step by step in the Ruby programming language
You may also check:How to resolve the algorithm Loops/N plus one half step by step in the Red programming language
You may also check:How to resolve the algorithm Loops/For step by step in the Rust programming language
You may also check:How to resolve the algorithm Short-circuit evaluation step by step in the D programming language