モジュール:数学

2年8月15日 (W) 17:03時点における (トーク | 投稿記録)による版

このモジュールについての説明文ページを モジュール:数学/doc に作成できます

local p = {}

function p.getLmc(num1, num2) --2数の最小公倍数を求める関数
	if type(num1) == number and type(num2) == number then
		if num1 == 0 or num2 == 0 then
			return 0
		end
		if num1 == num2 then
			return num1
		end
		a, b = 1
		while num1 ~= num2 do
			if a*num1 > b*num2 then
				b = b + 1
			else
				a = a + 1
			end
		end
		return num1
	else
		return "'''関数 getLmc: 引数には数値のみを入力してください。'''"
	end
end

return p