Pike    up http://pike.ida.liu.se/
  similar languages: C   C#   C++   C-Talk   D   Cilk   Java   Objective-C   TOM  
 


  Factorial   Michael Neumann
/* 
 * Berechnen der Fakultät
 */


// Fakultät-Funktion
int fac(int n)
{
   if(n > 1) return n * fac(n-1);
   else return 1;
} 

// Hauptprogramm
void main() 
{
   write("" + fac(6));
}
Calculates the factorial. Results 720.


 Hello World   Michael Neumann
// Hello World in Pike

void main()
{
   write("Hello World\n");
}
Prints "Hello World" onto the screen.


 Squares (1)   Michael Neumann
void main() 
{
   string str = "";
   
   for(int i=1; i<=10; i++)
   {
      str += i*i + " ";
   }
   
   write(str);
}
Outputs the squares from 1 to 10.


 Squares (2)   Michael Neumann
void main() 
{
   array arr = ({ 1,2,3,4,5,6,7,8,9,10 });
     
   foreach(arr, int i)
   {
      write(i*i + " ");
   }
}
Outputs the squares from 1 to 10.