Sum of squares: Difference between revisions

→‎{{header|Euler}}: Sybntax highlight with Mediawiki markup
imported>GoulashAmateur
(Add functional Common Lisp version)
(→‎{{header|Euler}}: Sybntax highlight with Mediawiki markup)
Line 1,165:
=={{header|Euler}}==
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&lt;- loop0;
temp <i &lt;- 0lo;
loop: i <- lo;'''begin'''
loop: begin temp &lt;- temp + term;
temp <'''if''' [ i &lt;- tempi + term1 ] &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 <-'''out''' sum( 1@i, 21, 3,'''length''' 4A, 5`A[i]*A[i]&apos; );
'''end''' $
out sum( @i, 1, length A, `A[i]*A[i]' )
end $
</syntaxhighlight>
 
=={{header|Euphoria}}==
3,037

edits