You can edit almost every page by Creating an account. Otherwise, see the FAQ.

Module:Herhaal symbolen

Uit EverybodyWiki Bios & Wiki
Ga naar:navigatie, zoeken

require('Module:No globals')

local p = {}

function p.main(frame)
	local n = tonumber(frame.args.n)
	assert(n, 'Geef een getal voor n')
	assert(n == math.floor(n), 'n moet een geheel getal zijn')
	local base = tonumber(frame.args.base or 10)
	assert(base, 'Geef een grondgetal')
	assert(base == math.floor(base), 'Grondgetal moet een geheel getal zijn')
	local digits, counts, outputs = {}, {}, {}
	for k,v in ipairs(frame.args) do
		digits[k] = v
		counts[k] = n % base
		n = (n - counts[k]) / base
	end
	counts[#counts] = counts[#counts] + n * base
	local tail = #digits + 1
	for k,v in ipairs(digits) do
		outputs[k] = v:rep(counts[tail - k])
	end
	return table.concat(outputs)
end

return p

Dit Module "Herhaal symbolen" is uit Wikipedia. De lijst van zijn auteurs is te zien in zijn historische.