aboutsummaryrefslogtreecommitdiffstats
path: root/picat
diff options
context:
space:
mode:
authorelioat <elioat@tilde.institute>2024-03-14 18:47:17 -0400
committerelioat <elioat@tilde.institute>2024-03-14 18:47:17 -0400
commitaa208e440331a4b4ed5d7ca1af6a0962adec628e (patch)
tree4b8d81705154952c8e59c70ba69a21231578d6cc /picat
parent9e3d80a7dcb9530fefaee76643e3943570ac0d2d (diff)
downloadtour-aa208e440331a4b4ed5d7ca1af6a0962adec628e.tar.gz
*
Diffstat (limited to 'picat')
-rw-r--r--picat/fib.pi18
1 files changed, 18 insertions, 0 deletions
diff --git a/picat/fib.pi b/picat/fib.pi
new file mode 100644
index 0000000..2f852cd
--- /dev/null
+++ b/picat/fib.pi
@@ -0,0 +1,18 @@
+main =>
+S = 0,
+ I = 1,
+ F = fib(I),
+ while (F <= 4000000)
+ if (F mod 2 == 0) then
+ S := S+F
+ end,
+ I := I+1,
+ F := fib(I)
+ end,
+ printf("Sum of the even-valued terms is %w%n",S).
+main([A1]) =>
+ printf("fib(%s)=%w%n",A1,A1.to_integer().fib()).
+table
+fib(1) = 1.
+fib(2) = 2.
+fib(N) = fib(N-1)+fib(N-2). \ No newline at end of file