Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- begin
- define factorial(number) begin
- when (number < 1) do begin
- return 1;
- end ;
- temp equal to number*factorial(number - 1);
- return temp;
- end
- define exponent(base,exp) begin
- temp equal to base;
- where start = 1 until exp do begin
- base equal to base * temp;
- end ;
- return base;
- end
- a equal to 0;
- b equal to 5;
- d equal to "END OF PROGRAM";
- e equal to 1;
- exampleBase equal to 3;
- exampleExp equal to 3;
- printing("MATH EXPRESSIONS");
- printing("----------------");
- write("3 raised to 3 (Function): ");
- answer equal to exponent(exampleBase,exampleExp);
- printing(answer);
- write("RECURSIVE FUNCTION - The factorial of ");
- write(b);
- write(" is: ");
- c equal to factorial(b);
- printing(c);
- write("ARRAY TEST - ");
- define list() begin
- return [7,8,9];
- end
- array equal to list();
- printing("array consists of 3 elements");
- write("element 1: "); printing(array[0]);
- write("element 2: "); printing(array[1]);
- write("element 3: "); printing(array[2]);
- write("element 1 + 2 = "); printing(array[0]+array[1]);
- write("element 2 * 3 = "); printing(array[1]*array[2]);
- printing("WHILE CONSTRUCT: AS LONG AS (<expr>) DO BEGIN <code> END");
- as long as (a < 50) do begin
- a equal to a + 1;
- end ;
- printing(a);
- printing("DO-WHILE LOOP CONSTRUCT: PERFORM BEGIN <code> END AS LONG AS (<expr>)");
- perform begin
- e equal to e + 3;
- printing(e);
- end as long as (e < 75) ;
- f equal to 0;
- cond equal to 14;
- printing("FOR LOOP CONSTRUCT: WHERE <counter start> UNTIL <number of iterations> DO BEGIN <code> END");
- where g = 0 until cond do begin
- f equal to f + 1;
- printing(f);
- end ;
- return d;
- end
Advertisement
Add Comment
Please, Sign In to add comment