「モジュール:数学」の版間の差分

ナビゲーションに移動 検索に移動
編集の要約なし
編集の要約なし
編集の要約なし
2行目: 2行目:


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

回編集

案内メニュー