[Plain] Description
For the expression n ^ 2 + n + 41, when n is an integer (including x, y) in the range of (x, y) (-39 <= x, y <= 50) to determine whether the value of this expression is a prime number.
Input
There are multiple groups of input data. Each group occupies one row and consists of two integers x and y. When x = 0 and y = 0, the input is complete and the row is not processed.
Output
For values in each given range, if the expression value is a prime number, "OK" is output; otherwise, "Sorry" is output, and each group of output occupies one row.
Sample Input
0 1
0 0
Sample Output
OK
Description
For the expression n ^ 2 + n + 41, when n is an integer (including x, y) in the range of (x, y) (-39 <= x, y <= 50) to determine whether the value of this expression is a prime number.
Input
There are multiple groups of input data. Each group occupies one row and consists of two integers x and y. When x = 0 and y = 0, the input is complete and the row is not processed.
Output
For values in each given range, if the expression value is a prime number, "OK" is output; otherwise, "Sorry" is output, and each group of output occupies one row.
Sample Input
0 1
0 0
Sample Output
OK
[Plain] # include <stdio. h>
Int main ()
{
Int I;
Int j;
Int n;
Int x;
Int y;
Int flag;
Int mark;
While (scanf ("% d", & x, & y )! = EOF, x! = 0 | y! = 0)
{
Mark = 1;
Flag = 1;
For (I = x; I <= y; I ++)
{
N = I * I + 41;
For (j = 2; j <= n/2; j ++)
{
If (n % j = 0)
{
Flag = 0;
Break;
}
}
If (flag = 0)
{
Mark = 0;
Break;
}
}
If (mark)
{
Printf ("OK \ n ");
}
Else
{
Printf ("Sorry \ n ");
}
}
Return 0;
}
# Include <stdio. h>
Int main ()
{
Int I;
Int j;
Int n;
Int x;
Int y;
Int flag;
Int mark;
While (scanf ("% d", & x, & y )! = EOF, x! = 0 | y! = 0)
{
Mark = 1;
Flag = 1;
For (I = x; I <= y; I ++)
{
N = I * I + 41;
For (j = 2; j <= n/2; j ++)
{
If (n % j = 0)
{
Flag = 0;
Break;
}
}
If (flag = 0)
{
Mark = 0;
Break;
}
}
If (mark)
{
Printf ("OK \ n ");
}
Else
{
Printf ("Sorry \ n ");
}
}
Return 0;
}