answersLogoWhite

0


Best Answer

Function isPrime(ByVal n As Integer) As Boolean

If n < 2 Then

Return False

End If

Dim sqrtn As Integer = Math.Sqrt(n) + 1

For i As Integer = 2 To sqrtn

If (n Mod i) = 0 Then

Return False

End If

Next

Return True

End Function

User Avatar

Wiki User

โˆ™ 14y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program in vb to check whether a no is prime or not?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

Write an algorithm to check whether a number is a prime number or not?

You can write out this algorithm. This will then be programmed into the device to make determining prime numbers easier.


Write a java programme to check whether the number is twin prime or not?

Find a prime number, add 2 to the number. Check if the new number is prime. IE : 3 is prime. 3+2 =5. 5 is prime. (3,5) are twin primes.


With a given big integer number which is the product of two prime numbers how do you find them?

First write a program to generate the prime number. After one prime number was generated, divide the big int number by the prime number. If the remainder is zero then quotient is the second prime number ( also it is important to check whether the quotient is prime number or not because sometimes you will get wrong answer). Repeat the process until you get the result.


Write a shell script to check whether the given input is prime or not?

shell script for check whether the given no is prime or not??echo "input any number:"read nono=`expr $no`i=`expr 2`while [ $i -lt $no ]doif [ `expr $no % $i` -eq 0];thenecho "$no is not a prime no.."break 2fii=`expr $i +1`doneif [ $i -eq $no ];thenecho "$no is a PRIME no..."fi


How do you write a VBnet program to find the prime numbers between 100 to 200?

VBnet program to find the prime numbers between 100 to 200?


What is the largest prime no that is stored in 8 bit pattern?

Write your own prime number program and find out.


How can I write a program to display prime numbers from 1 to 100?

Write a function that implements an algorithm that checks to see if a particular integer is prime (returning a boolean). Write a program that uses that function on each number from 1 to 100, and if true, displays that number.


How do you find prime numbers between 2 and 70?

You can check each individual number, whether it is a prime number. For numbers below 100, it is enough to check whether they are divisible by 2, by 3, by 5, and by 7. If a number is divisible by none of these, it is a prime number.


How do you write a C plus plus program that will display the first 10 positive prime numbers?

By learning how to program on C+.


How do you write a program in objective c numbers 1-100 prime numbers?

fdsgfhgdfhgdf


Does any whole number multiply to get 29?

29 is a prime number, meaning it has no smaller factors. For any number up to 120, to check whether it is prime or not, it is sufficient to check whether it is divisible by the first four prime numbers (2, 3, 5 and 7).


Write a C program to find the sum of all prime numbers?

Since there is an infinite set of prime numbers the answer would be infinity.