#!/usr/bin/env tclsh gets stdin now gets stdin line foreach i [split $line ,] { if {$i ne "x"} {lappend ids $i} } set wait 0 while 1 { foreach i $ids { if {($now + $wait) % $i == 0} { puts "$i $wait [expr {$i * $wait}]" exit } } incr wait }