Mistivia 3 months ago
parent
commit
05b6011d5b
1 changed files with 21 additions and 0 deletions
  1. 21 0
      0006/main.tcl

+ 21 - 0
0006/main.tcl

@@ -0,0 +1,21 @@
+proc square {x} {
+    return [expr {$x * $x}]
+}
+
+proc sum_of {x} {
+    set result 0
+    for {set i 1} {$i <= $x} {incr i} {
+        set result [expr {$result + $i}]
+    }
+    return $result
+}
+
+proc sum_of_square {x} {
+    set result 0
+    for {set i 1} {$i <= $x} {incr i} {
+        set result [expr {$result + [square $i]}]
+    }
+    return $result
+}
+
+puts [expr {[square [sum_of 100]] - [sum_of_square 100]}]