How to resolve the algorithm Sum of squares step by step in the Forth programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Sum of squares step by step in the Forth 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 Forth programming language
Source code in the forth programming language
: fsum**2 ( addr n -- f )
0e
dup 0= if 2drop exit then
floats bounds do
i f@ fdup f* f+
1 floats +loop ;
create test 3e f, 1e f, 4e f, 1e f, 5e f, 9e f,
test 6 fsum**2 f. \ 133.
You may also check:How to resolve the algorithm Sorting algorithms/Cocktail sort step by step in the VBA programming language
You may also check:How to resolve the algorithm First-class functions/Use numbers analogously step by step in the Elena programming language
You may also check:How to resolve the algorithm 24 game step by step in the Swift programming language
You may also check:How to resolve the algorithm Write float arrays to a text file step by step in the Sidef programming language
You may also check:How to resolve the algorithm Call a foreign-language function step by step in the BBC BASIC programming language