Private Sub Command1_Click() Dim I, N As Integer N = Val(Text1.Text) For I = 2 To N - 1 If N Mod I = 0 Then Print "THE NUMBER IS NOT A PRIME NUMBER" Exit Sub End If Next I Print "THE NUMBER IS A PRIME NUMBER" End Sub Private Sub Command2_Click() Text1.Text = "" Text1.SetFocus End Sub Private Sub Command3_Click() End End Sub
I suggest you write an outer loop, that loops through all the numbers from 1 to 50. Call the variable that controls the loop something like "number".Then, initially assume the number is a prime (with a variable such as "isprime"); and write another loop that compares whether the number is divisible by any number from 2 to number-1. Call the controlling variable "factor". If number is divisible by factor, then it is not a prime, and you can exit the loop. At the end of the inner loop, if the variable "isprime" is still true, then you print the number.
This would require some computer knowledge. It can make it easier to find out the prime numbers without figuring it out in your head.
Cls input "enter the no. You want to check", a if a <=0 then print "only natural nos allowed" if a <=0 end let m = a - 1 for i = m to 2 step -1 if a mod i = 0 then print "not prime" if a mod i = 0 then end next i print "prime" end
i=2 rem=1 echo "Enter a number" read num if [ $num -lt 2 ] then echo "$num is not prime" exit 0 fi while [ $i -le `expr $num / 2` -a $rem -ne 0 ] do rem=`expr $num % $i` i=`expr $i + 1` done if [ $rem -ne 0 ] then echo "$num is prime" else echo "$num is not prime" fi
10 input "enter a no."; n 20 for i = 1 to n 30 if n mod i = 0 then c = c +1 40 next i 50 if c = 2 then print "prime number" else print "not a prime number" 60 end
An infinite number of pages are required to print an infinitely large prime number.
PRINT 2,3,5,7,11,13,17,19,23,29,31,37
Private Sub Command1_Click() Dim I, N As Integer N = Val(Text1.Text) For I = 2 To N - 1 If N Mod I = 0 Then Print "THE NUMBER IS NOT A PRIME NUMBER" Exit Sub End If Next I Print "THE NUMBER IS A PRIME NUMBER" End Sub Private Sub Command2_Click() Text1.Text = "" Text1.SetFocus End Sub Private Sub Command3_Click() End End Sub
Begin Read num for(i=2; i<num; i++) if(num%2==0) then print "the number is not a prime no."; else if print "the number is prime"; end if Stop
You can try the below FoxPro code: Report Form "C:\Project\Reports\PrintReport" Preview Report Form "C:\Project\Reports\PrintReport" To Printer Prompt Nodialog Preview
I suggest you write an outer loop, that loops through all the numbers from 1 to 50. Call the variable that controls the loop something like "number".Then, initially assume the number is a prime (with a variable such as "isprime"); and write another loop that compares whether the number is divisible by any number from 2 to number-1. Call the controlling variable "factor". If number is divisible by factor, then it is not a prime, and you can exit the loop. At the end of the inner loop, if the variable "isprime" is still true, then you print the number.
bghjg
wap to print all the arnstrong no. between 100&1000
Q.1 Write a program to print first ten odd natural numbers. Q.2 Write a program to input a number. Print their table. Q.3 Write a function to print a factorial value.
Use a counted loop in the closed range [1:100]. If the count is in the closed range [40:50], print the number. For all other numbers outwith this range, only print the number if it is prime.
This would require some computer knowledge. It can make it easier to find out the prime numbers without figuring it out in your head.