输入一个任意整数判断能否被3和5整除

来源:百度知道 编辑:UC知道 时间:2024/06/03 21:55:19
是在VB里用
1能被3整除
2能被5整除
3能同时被3与5整除
4都不能整除

dim n as integer
n=inputbox("请输入一个整数:")
if n mod 3=0 then
print "能被3整除。"
elseif n mod 5=0 then
print "能被5整除。"
else
print "不能被3或5整除。"
end if

将输入的整数赋值给n
if n mod 3=0 and n mod 5=0 then msgbox"能被3和5整除"
if n mod 3=0 or n mod 5=0 then msgbox"能被3或5整除"