Summation ---
 These code samples created by Tim Van Dusen

 Languages used:
   ti89 calculator, C/C++, VisualBasic, BASIC, assembler,
   LabView, PHP/HTML, cgi/perl, python, Fortran, Maple10

 Yours to study, copy, use ....



ti89 calculator  screenshot 
output screen 
  3 
( k + 5 )
 n = 1  15
 
command prompt 
( k + 5, n, 1, 3 )



C/C++   screenshot 

 BYTE k=0, n;
 for( n = 1; n < 4; n++ )
 { k = k + 5; }
 return;



VisualBasic   screenshot 

 Private Sub btnGetSum_Click()
    Dim k, n As Byte: k = 0
    For n= 1 To 3
        k = k + 5
    Next
 End Sub



BASIC   screenshot 

 10 : k = 0
 20 : FOR n = 1 TO 33
 30 : k = k + 5
 40 : NEXT
 50 : PRINT k



assembler   screenshot 
u_cnt equ 3;upper count limit - over sum symbol
 ;DX will be our "k" variable
  
mov cx, u_cnt;counter
mov dl, 030;start at ascii 0 for one's
mov dh, 030;- ditto for ten's
  
LoopStart: 
add dl, 5;inc one's counter until cx is done
cmp dl, 039;if at ten, print the first digit
jc noIncDH 
inc dh 
mov dl, 030 
  
noIncDH: 
dec cx 
jz doDone 
jmp LoopStart 
  
doDone: 
rol dx, 8;get ten's counter in DL
mov ah, 6;DOS console write
int 021;DOS interrupt
rol dx, 8;get one's counter back in DH
int 021;DOS interrupt
mov ah, 04c;DOS termination request
int 021;DOS interrupt



LabView   screenshot 

 LabView is an iconic programming language.
 See the screenshot for code and output results.



PHP/HTML   screenshot 

<html><head>
<title>Summation PHP</title></head>
<body bgcolor=#ffffff text=0>
<table width=250 border=0 cellpadding=0>
<tr> <td width=50><font face=verdana color=#0 size=2>  3
<td width=100> <td> 
<tr><td>
<font face="Times New Roman" color=#0 size=8>&#931;
<td><font face=verdana color=#0 size=2>( k + 5 )<td> </tr>
<tr><td><font face=verdana color=#0 size=2> n=1
<td> </tr>
<tr><td><font face=verdana color=#0 size=2> results
<td <td>
<?php
   $k=0; $n=0;
   for( $n = 1; $n < 4; $n++ ) { $k = $k + 5; }
   echo 'k = '.$k;
?>
</td></tr></table>
<body></html>



CGI-Perl   screenshot 

#! /usr/bin/perl5
print"  Content-type: text/html\r\n\r\n";
print"  <title>Summation CGI Perl</title></head>";
print"  <body bgcolor=#ffffff text=0>";
print"  <table width=250 border=0 cellpadding=0>";
print"  <tr> <td width=50>";
print"  <font face=verdana color=#0 size=2>  3";
print"  <td width=100> <td> ";
print"  <tr><td>";
print"  <font face="Times New Roman" color=#0 size=8>&#931";
print"  <td><font face=verdana color=#0 size=2>";
print"  ( k + 5 )<td> </tr>";
print"  <tr><td><font face=verdana color=#0 size=2> n=1";
print"  <td> </tr>";
print"  <tr><td><font face=verdana color=#0 size=2> results";
print"  <td>";
   $k=0; $n=0;
   for( $n = 1; $n < 4; $n++ ) { $k = $k + 5; }
print "k = ".$k;
print "</td></tr></table><body></html>";



Python   screenshot 

 #! /usr/bin/env python
 def main
():
       n = int(1)
       k = int(0)
              for n in range(3):
              k = k+5
       print k
 main()



Fortran   screenshot 

 ! ---------------------------------------------------
 ! Fortran summation example.
 ! My attempt with Fortran - please excuse syntax errs.
 ! Thanks to Professor Hamzeh Roumani at the following
 ! Web site for compiler
 ! http://www.cse.yorku.ca/~roumani/fortran/ftn.htm
 ! ---------------------------------------------------

 integer*2 sum
 print*, "Summation using Fortran"
 call doSum(sum)
 print*, "After summation", sum
 end

 subroutine doSum(sum)
 integer*2 sum, i
 sum = 0
 do 10 i = 1, 3
       sum = sum + 5
       write(*,*) 'sum =', sum
 10 continue

 end



Maple10   screenshot 

>      k:= 0
 



k:= 0
>
 
 



  15
>
  k := 0; for i to 3 do k := k+5; print(k) end do;
 



k:= 0
   5
  10
  15