Dim check As Integer check = 1 Dim num As Integer num = TextBox1.Text For i = 2 To (num – 1) If num Mod i = 0 Then check = 0 Exit For End If Next If check = 0 Then MsgBox“Not prime” Else MsgBox“prime” End If End Sub. % Given a range of integers by its lower and upper limit, construct a% list of all prime numbers in that range.:- ensureloaded(p31).% make sure isprime/1 is loaded% primelist(A,B,L):- L is the list of prime number P with A primelist(A,B,L):- A =primelist(A,B,L):- A1 is (A // 2). 2 + 1, plist(A1,B,L).
- Learn C By Examples Time
- C Programming Useful Resources
- Selected Reading
Any whole number which is greater than 1 and has only two factors that is 1 and the number itself, is called a prime number. Other than these two number it has no positive divisor. For example −
Few prime number are − 1, 2, 3, 5 , 7, 11 etc.
Algorithm
Algorithm of this program is very easy −
Pseudocode
We can draft a pseudocode of the above algorithm as follows −
Implementation
![Check prime number Check prime number](/uploads/1/2/6/2/126275680/909104629.jpg)
Implementation of this algorithm is given below −
Output
Output of the program should be −
mathematical_programs_in_c.htm
Prolog Problems > 2. Arithmetic
|