using
System;
using
System.Collections.Generic;
using
System.Linq;
class
GFG {
static
string
Calc(
string
binary,
string
interpret_language)
{
int
tmp = 0;
string
baseString =
"01"
;
for
(
int
n = 0; n < binary.Length; n++) {
char
digit = binary[binary.Length - 1 - n];
tmp += baseString.IndexOf(digit)
* (
int
)Math.Pow(baseString.Length, n);
}
string
resulting_number =
""
;
while
(tmp > 0) {
resulting_number += interpret_language
[tmp % interpret_language.Length];
tmp /= interpret_language.Length;
}
char
[] resultChars = resulting_number.ToCharArray();
Array.Reverse(resultChars);
resulting_number =
new
string
(resultChars);
return
resulting_number;
}
static
bool
IsPrime(
string
N)
{
int
n = Int32.Parse(N);
int
c = 1;
for
(
int
i = 2; i <= n; i++) {
if
(n % i == 0) {
c++;
}
}
if
(c == 2) {
return
true
;
}
return
false
;
}
static
void
Main(
string
[] args)
{
string
binary =
"111"
;
int
L = 3;
int
R = 10;
List<
char
> bases =
new
List<
char
>{
'0'
,
'1'
,
'2'
,
'3'
,
'4'
,
'5'
,
'6'
,
'7'
,
'8'
,
'9'
,
'A'
,
'B'
,
'D'
,
'E'
,
'F'
,
'G'
,
'H'
,
'I'
,
'J'
,
'K'
,
'L'
,
'M'
,
'N'
,
'O'
,
'P'
,
'Q'
,
'R'
,
'S'
,
'T'
,
'U'
,
'V'
,
'W'
,
'X'
,
'Y'
,
'Z'
};
List<
char
> b = bases.GetRange(0, R);
int
count = 0;
for
(
int
i = 0; i <= R - L; i++) {
List<
char
> list = b.GetRange(0, L + i);
string
interpret_language
=
new
string
(list.ToArray());
string
resulting_number
= Calc(binary, interpret_language);
if
(IsPrime(resulting_number)) {
count++;
}
}
Console.WriteLine(count);
}
}