--Bytelandian Exchange 1 --Initialize coinValue = 0 --Get positive integer while( coinValue < 1 ) do print( "Insert coin:") coinValue = math.floor( tonumber( io.read() ) ) end --Exchange coin recursively function exchange( coin ) if( coin == 0 ) then return 1 else return exchange( math.floor( coin/2 ) ) + exchange( math.floor( coin/3 ) ) + exchange( math.floor( coin/4 ) ) end end --Output print( "You get back " .. exchange( coinValue ) .. " 0-value coins." )