[go: up one dir, main page]

login
A348292
Binary expansion of the smallest binary number starting with a(0)=1 that is prime when the final number is 1 and composite when the final number is 0.
0
1, 1, 1, 0, 1, 1, 0, 0, 0, 0, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1
OFFSET
0
COMMENTS
The prime values generated by this sequence are also generated by A084435 (except for 2, which is only listed in A084435).
REFERENCES
Donald E. Knuth, The Art of Computer Programming, Vol. 2, Seminumerical Algorithms, problem 39, page 76.
EXAMPLE
For example, the binary numbers 1, 11, and 111 expressed in base 10 are 1, 3, and 7, which are prime with the exception of the first term. The next term in the binary number must be 0 because the binary number 1111 is composite.
MATHEMATICA
seq[len_] := Module[{s = {1}, k = 1, m = 1, d}, While[k < len, m *= 2; d = Boole@PrimeQ[m + 1]; m += d; AppendTo[s, d]; k++]; s]; seq[100] (* Amiram Eldar, Oct 19 2021 *)
PROG
(HTML/JavaScript)
<html>
<script>
binary="1";
for(k=0; k<30; k++)
{
if(isprime(parseInt(binary+"1", 2))==true)
{
binary=binary+"1";
}
if(isprime(parseInt(binary+"1", 2))==false)
{
binary=binary+"0";
}
}
document.write(binary);
function isprime(x)
{
for(i=2; i<(x-1); i++)
{
if(x%i==0)
{
return false;
}
}
return true;
}
</script>
</html>
CROSSREFS
Cf. A084435.
Sequence in context: A374048 A090174 A165556 * A127243 A127248 A266298
KEYWORD
nonn,base,cons
AUTHOR
Michael R. Page, Oct 19 2021
STATUS
approved