Zeckendorf in Tcl

Published on 11 April 2026 (Updated: 11 April 2026)

Welcome to the Zeckendorf in Tcl page! Here, you'll find the source code for this program as well as a description of how the program works.

Current Solution

proc usage {} {
	puts "Usage: please input a non-negative integer"
    exit 1
}

proc zeckendorf {n} {
    set result {}
    set a 1
    set b 2

    while {$b <= $n} {
        lassign [list $b [expr {$a + $b}]] a b
    }

    while {$n > 0} {
        if {$a <= $n} {
            set n [expr {$n - $a}]
            lappend result $a
        }
        lassign [list [expr {$b - $a}] $a] a b
    }

    return $result
}

if {$argc != 1} { usage }
lassign $argv arg

if {![string is integer -strict $arg] || $arg < 0} {
    usage
}

puts [join [zeckendorf $arg] ", "]

Zeckendorf in Tcl was written by:

If you see anything you'd like to change or update, please consider contributing.

How to Implement the Solution

No 'How to Implement the Solution' section available. Please consider contributing.

How to Run the Solution

No 'How to Run the Solution' section available. Please consider contributing.