How to resolve the algorithm Sum and product of an array step by step in the APL programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Sum and product of an array step by step in the APL programming language
Table of Contents
Problem Statement
Compute the sum and product of an array of integers.
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Sum and product of an array step by step in the APL programming language
Source code in the apl programming language
sum ← +/ ⍝ sum (+) over (/) an array
prod ← ×/ ⍝ product (×) over (/) an array
a ← 1 2 3 4 5 ⍝ assign a literal array to variable 'a'
sum a ⍝ or simply: +/a
15
prod a ⍝ or simply: ×/a
120
⎕ ← (+/ ⍮ ×/) 1 2 3 4 5
15 120
You may also check:How to resolve the algorithm FizzBuzz step by step in the Oberon-2 programming language
You may also check:How to resolve the algorithm Fibonacci sequence step by step in the OCaml programming language
You may also check:How to resolve the algorithm Trabb Pardo–Knuth algorithm step by step in the REXX programming language
You may also check:How to resolve the algorithm Compare a list of strings step by step in the Elena programming language
You may also check:How to resolve the algorithm Stirling numbers of the first kind step by step in the jq programming language