“输入任意正整数,输出该数的所有因子及因子个数”在vb中怎么编程

2024-12-29 05:03:03
推荐回答(1个)
回答1:

dim number as integer '输入的正整数
dim yz as integer '因子
dim num as integer '因子个数
dim i as integer '循环变量

num = 0
print number + "的因子有:"
for i=1 to numner/2
if (number\i)*i=number then
num = num + 1
printf i
endif
next i
print "共计"+num+"个因子"