vb编程 输入一个数看看是不是质数,要用IsPrime这个方程Prime NumbersA prime number is a number that can be evenly divided by only itself and 1.Forexample,the number 5 is prime because it can be evenly divided by only 1 and 5.Thenumber

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/20 08:55:28
vb编程输入一个数看看是不是质数,要用IsPrime这个方程PrimeNumbersAprimenumberisanumberthatcanbeevenlydividedbyonlyitselfand

vb编程 输入一个数看看是不是质数,要用IsPrime这个方程Prime NumbersA prime number is a number that can be evenly divided by only itself and 1.Forexample,the number 5 is prime because it can be evenly divided by only 1 and 5.Thenumber
vb编程 输入一个数看看是不是质数,要用IsPrime这个方程
Prime Numbers
A prime number is a number that can be evenly divided by only itself and 1.For
example,the number 5 is prime because it can be evenly divided by only 1 and 5.The
number 6,however,is not prime because it can be evenly divided by 1,2,3,and 6.
Write a Boolean function named IsPrime which takes an integer as an argument
and returns true if the argument is a prime number or false otherwise.Use the func-
tion in an application that lets the user enter a number and then displays a message
indicating whether the number is prime.

vb编程 输入一个数看看是不是质数,要用IsPrime这个方程Prime NumbersA prime number is a number that can be evenly divided by only itself and 1.Forexample,the number 5 is prime because it can be evenly divided by only 1 and 5.Thenumber
Private Function isPrime(intIndicated As Integer) As Boolean
If intIndicated >= 2 Then
isPrime = True
For i = 2 To intIndicated - 1
If intIndicated Mod i = 0 Then isPrime = False: Exit For
Next i
Else
isPrime = False
End If
End Function
Private Sub Command1_Click()
Dim intInput As Integer
intInput = InputBox("Please enter a integer :", "Enter a number")
If isPrime(intInput) Then
MsgBox intInput & " is a prime number."
Else
MsgBox intInput & " is NOT a prime number."
End If
End Sub
另外,你用的是VB6还是.NET,我上面是按VB6写的.

vb编程 输入一个数看看是不是质数,要用IsPrime这个方程Prime NumbersA prime number is a number that can be evenly divided by only itself and 1.Forexample,the number 5 is prime because it can be evenly divided by only 1 and 5.Thenumber VB编程:输入一个数,求这个数与其倒数之和坐等 麻烦快点 谢谢 用vb编程:输入三个数,求出最大的数 用vb编程:任意输入3个数,输出其中最大值, 素数(质数):就是一个大于等于2的整数,并且只能被1和本身整除,而不能被其它整除数的数.输入一个数.判断他/她是否是素数.还是VB编程、、 用vb编程 任意输入一整数,判断其奇偶性. C语言编程:输入一个数判断是否为素数(质数),输出判断结果信息(prime number素数). VB编程求1-1000以内任意两数间的所有质数!就是要在窗体内任意输入两个自然数(均小于1000)显示这两个数之间所有质数. 求VB编程代码:判断一个数是否是素数? VB编程题:任意输入10个整型数,显示其中奇数和偶数的个数,.. 任意输入一个数,来判断其是否是素数.若为质数,显示yes,否则,显示no.快用C语言编程 vb!输入一个四位数,求四个数字之和,判断和是不是质数 求VB编程:任意输入10个数,求奇数的个数,偶数的和,以及最后一个偶数. 任意输入一个自整数,判断是不是质数(用C语言编程) 如何判断一个数是不是质数 怎么确定一个数是不是质数 怎样判断一个数是不是质数? c语言编程题目 整数n=p*q,p和q为质数,且p≠q,我们称n为D-Prime,请写个程序判断一个数是不是D_Prime.输入第一行是一个整数K,表示样例的个数.以后每行是一个整数x,(1 ≤ x ≤ 100,000,000);输出每行输