main.tcl 411 B

123456789101112131415161718192021
  1. proc square {x} {
  2. return [expr {$x * $x}]
  3. }
  4. proc sum_of {x} {
  5. set result 0
  6. for {set i 1} {$i <= $x} {incr i} {
  7. set result [expr {$result + $i}]
  8. }
  9. return $result
  10. }
  11. proc sum_of_square {x} {
  12. set result 0
  13. for {set i 1} {$i <= $x} {incr i} {
  14. set result [expr {$result + [square $i]}]
  15. }
  16. return $result
  17. }
  18. puts [expr {[square [sum_of 100]] - [sum_of_square 100]}]