diff --git a/pcl/programs/factorial.input b/pcl/programs/factorial.input new file mode 120000 index 0000000..041a274 --- /dev/null +++ b/pcl/programs/factorial.input @@ -0,0 +1 @@ +../../alan/programs/factorial.input \ No newline at end of file diff --git a/pcl/programs/factorial.pcl b/pcl/programs/factorial.pcl new file mode 100644 index 0000000..9f5c7f4 --- /dev/null +++ b/pcl/programs/factorial.pcl @@ -0,0 +1,20 @@ +program factorial; + +var n : integer; + +function fact (x : integer) : integer; +begin + if x <= 1 then + result := 1 + else + result := x * fact(x - 1) +end; + +begin + n := readInteger(); + writeString("The factorial of "); + writeInteger(n); + writeString(" is "); + writeInteger(fact(n)); + writeString("\n") +end. diff --git a/pcl/programs/factorial.result b/pcl/programs/factorial.result new file mode 120000 index 0000000..870c1c8 --- /dev/null +++ b/pcl/programs/factorial.result @@ -0,0 +1 @@ +../../alan/programs/factorial.result \ No newline at end of file diff --git a/pcl/programs/fibonacci.input b/pcl/programs/fibonacci.input new file mode 120000 index 0000000..1175d4a --- /dev/null +++ b/pcl/programs/fibonacci.input @@ -0,0 +1 @@ +../../alan/programs/fibonacci.input \ No newline at end of file diff --git a/pcl/programs/fibonacci.pcl b/pcl/programs/fibonacci.pcl new file mode 100644 index 0000000..a773fff --- /dev/null +++ b/pcl/programs/fibonacci.pcl @@ -0,0 +1,22 @@ +program fibonacci; + +var n : integer; + +function fib (x : integer) : integer; +begin + if x <= 0 then + result := 0 + else if x = 1 then + result := 1 + else + result := fib(x - 1) + fib(x - 2) +end; + +begin + n := readInteger(); + writeString("Fibonacci of "); + writeInteger(n); + writeString(" is "); + writeInteger(fib(n)); + writeString("\n") +end. diff --git a/pcl/programs/fibonacci.result b/pcl/programs/fibonacci.result new file mode 120000 index 0000000..9cf2791 --- /dev/null +++ b/pcl/programs/fibonacci.result @@ -0,0 +1 @@ +../../alan/programs/fibonacci.result \ No newline at end of file