When n is a positive integer, is the value of square + N + 11 of N necessarily prime?
no
n = 10
n = 11
There must be a factor of 11
Seek a programming problem code: input a positive integer, judge whether the positive integer is prime
C, right?
#include "stdafx.h"
#include "math.h"
int main()
{
int n,i;
Printf ("please enter a number");
scanf("%d",&n);
If ((n = = 2)) printf ("% d is prime", n));
else
{
For (I = 2; I = sqrt (n) printf ("% d is prime", n));
}
return 0;
}
VB programming: judge whether any positive integer n is prime
Such as the title, the requirement is programming
Complete programming
Private Sub Command1_ Click()
n= Text1.Text
For i = 2 To Int(Sqr(n))
If n Mod i = 0 Then
Msgbox "no"
Exit Sub
End If
Next i
Msgbox "yes"
End Sub