Sum of squares: Difference between revisions

Content added Content deleted
imported>GoulashAmateur
(Add functional Common Lisp version)
(→‎{{header|Euler}}: Sybntax highlight with Mediawiki markup)
Line 1,165: Line 1,165:
=={{header|Euler}}==
=={{header|Euler}}==
Using [[Jensen's Device]]
Using [[Jensen's Device]]
'''begin'''
<syntaxhighlight lang="euler">
'''new''' i; '''new''' A; '''new''' sum;
begin
sum &lt;- ` '''formal''' i; '''formal''' lo; '''formal''' hi; '''formal''' term;
new i; new A; new sum;
sum <- ` formal i; formal lo; formal hi; formal term;
'''begin'''
begin
'''new''' temp; '''label''' loop;
new temp; label loop;
temp &lt;- 0;
temp <- 0;
i &lt;- lo;
i <- lo;
loop: '''begin'''
loop: begin
temp &lt;- temp + term;
temp <- temp + term;
'''if''' [ i &lt;- i + 1 ] &lt;= hi '''then''' '''goto''' loop '''else''' 0
if [ i <- i + 1 ] <= hi then goto loop else 0
'''end''';
end;
temp
temp
'''end'''
end
&apos;;
';
A &lt;- ( 1, 2, 3, 4, 5 );

A <- ( 1, 2, 3, 4, 5 );
'''out''' sum( @i, 1, '''length''' A, `A[i]*A[i]&apos; )
'''end''' $
out sum( @i, 1, length A, `A[i]*A[i]' )
end $
</syntaxhighlight>


=={{header|Euphoria}}==
=={{header|Euphoria}}==