ZKX's LAB

请问怎么用VB编程列出50到150之间所有的素数?请写出过程,多谢啦! vb埃拉托斯特尼筛法

2020-07-26知识17

请问怎么用VB编程列出50到150之间所有的素数?请写出过程,多谢啦! Private Sub Command1_Click()Dim i As IntegerDim j As IntegerDim a(100)As IntegerDim k As Integerk=0For i=50 To 150For j=1 To iIf i Mod j=0 Thenx=x+1End IfNextIf x=2 Thena(k)=iText1.Text=Text1.Text&a(k)&\"/k=k+1Elsex=0End IfNextEnd Sub

#素数#sub

随机阅读

qrcode
访问手机版