cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A331044 a(n) is the greatest prime number of the form floor(n/10^k) for some k >= 0, or 0 if no such prime number exists.

This page as a plain text file.
%I A331044 #17 Nov 22 2024 08:56:30
%S A331044 0,0,2,3,0,5,0,7,0,0,0,11,0,13,0,0,0,17,0,19,2,2,2,23,2,2,2,2,2,29,3,
%T A331044 31,3,3,3,3,3,37,3,3,0,41,0,43,0,0,0,47,0,0,5,5,5,53,5,5,5,5,5,59,0,
%U A331044 61,0,0,0,0,0,67,0,0,7,71,7,73,7,7,7,7,7,79,0
%N A331044 a(n) is the greatest prime number of the form floor(n/10^k) for some k >= 0, or 0 if no such prime number exists.
%C A331044 In other words, a(n) is the greatest prime prefix of n, or 0 if every prefix of n is nonprime.
%C A331044 This sequence is a decimal variant of A039634.
%H A331044 Rémy Sigrist, <a href="/A331044/b331044.txt">Table of n, a(n) for n = 0..10000</a>
%F A331044 a(n) <= n with equality iff n = 0 or n is a prime number.
%F A331044 a(n) >= 0 with equality iff n belongs to A202259.
%e A331044 For n = 42:
%e A331044 - neither 42 nor 4 is a prime number,
%e A331044 - hence a(42) = 0.
%e A331044 For n = 290:
%e A331044 - 290 is not a prime number,
%e A331044 - 29 is a prime number,
%e A331044 - hence a(290) = 29.
%t A331044 A331044[n_] := NestWhile[Quotient[#, 10] &, n, # > 0 && !PrimeQ[#] &];
%t A331044 Array[A331044, 100, 0] (* _Paolo Xausa_, Nov 22 2024 *)
%o A331044 (PARI) a(n, base=10) = while (n, if (isprime(n), return (n), n\=base)); 0
%Y A331044 See A331045 for a similar sequence.
%Y A331044 Cf. A039634, A202259, A320584.
%K A331044 nonn,base
%O A331044 0,3
%A A331044 _Rémy Sigrist_, Jan 08 2020