求2--1000中,每个数有多少个不同的质因子,并要求输出如下的式子:
来源:学生作业帮 编辑:神马作文网作业帮 分类:综合作业 时间:2024/11/17 04:00:14
求2--1000中,每个数有多少个不同的质因子,并要求输出如下的式子:
2=2
3=3
4=2*2
...
100=2*2*5*5
用记事本编程
vb语言
急用
2=2
3=3
4=2*2
...
100=2*2*5*5
用记事本编程
vb语言
急用
Rem 大家看你一分也不给,都不来搭理你哈,小女子发扬一下助人为乐的奉献精神吧
Rem 窗体建一个Text1,一个Text2,MultiLine属性改为True,ScrollBars设置为2(垂直滚动条)
Option Explicit
Private Function isprime(Num As Long) As Boolean
If Num < 2 Then isprime = False:Exit Function
Dim i As Long
For i = 2 To Sqr(Num)
If (Num Mod i) = 0 Then
isprime = False
Exit Function
End If
Next i
isprime = True
End Function
Private Sub Form_Click()
Dim i As Long,j As Long,temp As Long,diff As Long
Dim primestr(2 To 1000) As String,nall(2 To 1000) As Integer,ndiff(2 To 1000) As Integer
'primestr存放质因子的分解因式,nall存放质因子总的数目,ndiff存放不同质因子的数目
Cls
Text1 = ""
Text2 = ""
For i = 2 To 1000
Print i & "=";
primestr(i) = i & "="
nall(i) = 0:ndiff(i) = 0
temp = i
If Not isprime(temp) Then
j = 2
diff = 0
Do While Not isprime(temp)
If temp Mod j = 0 Then
Print j & "*";
primestr(i) = primestr(i) & j & "*"
nall(i) = nall(i) + 1
If diff j Then ndiff(i) = ndiff(i) + 1:diff = j
temp = temp \ j
Else
Do
j = j + 1
Loop Until isprime(j)
End If
Loop
If isprime(temp) And temp j Then ndiff(i) = ndiff(i) + 1
Else
ndiff(i) = 1
End If
Print CStr(temp)
primestr(i) = primestr(i) & CStr(temp) & vbCrLf
nall(i) = nall(i) + 1
Next
'输出不同质因子的数目
'For i = 2 To 1000
'Text1 = Text1 & i & ":" & ndiff(i) & vbCrLf
'Next
'在Text2中输出分解因式,这个有点慢哈,1000个数太多了
'For i = 2 To 1000
'Text2 = Text2 & primestr(i)
'Next
End Su
Rem 窗体建一个Text1,一个Text2,MultiLine属性改为True,ScrollBars设置为2(垂直滚动条)
Option Explicit
Private Function isprime(Num As Long) As Boolean
If Num < 2 Then isprime = False:Exit Function
Dim i As Long
For i = 2 To Sqr(Num)
If (Num Mod i) = 0 Then
isprime = False
Exit Function
End If
Next i
isprime = True
End Function
Private Sub Form_Click()
Dim i As Long,j As Long,temp As Long,diff As Long
Dim primestr(2 To 1000) As String,nall(2 To 1000) As Integer,ndiff(2 To 1000) As Integer
'primestr存放质因子的分解因式,nall存放质因子总的数目,ndiff存放不同质因子的数目
Cls
Text1 = ""
Text2 = ""
For i = 2 To 1000
Print i & "=";
primestr(i) = i & "="
nall(i) = 0:ndiff(i) = 0
temp = i
If Not isprime(temp) Then
j = 2
diff = 0
Do While Not isprime(temp)
If temp Mod j = 0 Then
Print j & "*";
primestr(i) = primestr(i) & j & "*"
nall(i) = nall(i) + 1
If diff j Then ndiff(i) = ndiff(i) + 1:diff = j
temp = temp \ j
Else
Do
j = j + 1
Loop Until isprime(j)
End If
Loop
If isprime(temp) And temp j Then ndiff(i) = ndiff(i) + 1
Else
ndiff(i) = 1
End If
Print CStr(temp)
primestr(i) = primestr(i) & CStr(temp) & vbCrLf
nall(i) = nall(i) + 1
Next
'输出不同质因子的数目
'For i = 2 To 1000
'Text1 = Text1 & i & ":" & ndiff(i) & vbCrLf
'Next
'在Text2中输出分解因式,这个有点慢哈,1000个数太多了
'For i = 2 To 1000
'Text2 = Text2 & primestr(i)
'Next
End Su
数2450的因子数怎么求?有多少?
12个相同的小球放入编号为1,2,3,4的盒子中没要求每个盒子的小球数不小于编号数,问有多少种不同的放法
把20个相同的球全放入编号分别为1,2,3的三个盒子中,要求每个盒子中的球数不少于其编号数.则有多少种不同的方法
将500~1000之间不能被7整除的数输出,并要求一行输出8个数据.
C语言 求质因子输入一个整数(非质数),输出该数的所有质因子要求设计一个判断质数(素数)的函数,int issushu(
c语言 求出 [900,1000] 间有偶数个因子(这里因子不含1和自身)的数有多少个,其中
设计一个程序,能随机产生3个3位的正整数,且要求每个数的三位数字之和等于20,并输出结果
编写自定义函数count(intx),计算x的因子个数.利用函数找出并输出1到1000中有奇数
设n为正整数,证明:数2∧2∧n+2∧2∧(n-1)+1,至少有n个不同的质因子
n是满足下列条件的正整数中最小的数:(1)n是75的倍数(2)n恰有75个正整数因子,求n/7
将9个大小相同的小球放入编号为1,2,3的三个盒子中,要求每个盒子内的球数不小于该盒子的编号数,一共有______种不同
求高手指教,关于涂色问题,五种不同的颜色涂如下4个区域要求相邻区域颜色不相同,则有多少种方案?