How to resolve the algorithm Sum of squares step by step in the BCPL programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Sum of squares step by step in the BCPL programming language
Table of Contents
Problem Statement
Write a program to find the sum of squares of a numeric vector. The program should work on a zero-length vector (with an answer of 0).
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Sum of squares step by step in the BCPL programming language
Source code in the bcpl programming language
get "libhdr"
let sumsquares(v, len) =
len=0 -> 0,
!v * !v + sumsquares(v+1, len-1)
let start() be
$( let vector = table 1, 2, 3, 4, 5, 6, 7, 8, 9, 10
writef("%N*N", sumsquares(vector, 10))
$)
You may also check:How to resolve the algorithm Detect division by zero step by step in the Julia programming language
You may also check:How to resolve the algorithm Greyscale bars/Display step by step in the AutoHotkey programming language
You may also check:How to resolve the algorithm Continued fraction/Arithmetic/G(matrix ng, continued fraction n1, continued fraction n2) step by step in the Icon programming language
You may also check:How to resolve the algorithm Tonelli-Shanks algorithm step by step in the PicoLisp programming language
You may also check:How to resolve the algorithm Shell one-liner step by step in the Oforth programming language