सी ++ 389 बाइट्स
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/miller_rabin.hpp>
using namespace boost::random;typedef boost::multiprecision::cpp_int Z;int main(int,char**v){mt19937 m(clock());independent_bits_engine<mt11213b,256,Z>g(m);Z n{v[1]},p;while(p++<=n)if(miller_rabin_test(p,25,g)&&p.convert_to<std::string>().find( "666" )!=-1)std::cout<<p<<" ";}
यह एक पूर्ण कार्यक्रम है!
इसे संकलित करने के लिए आपको Boost की आवश्यकता होगी। (या अपने पसंदीदा ऑनलाइन सी ++ शेल में कॉपी और पेस्ट करें।)
इसे एन -कमांड दे रहे एन -लाइन से चलाएं तर्क के रूप में ।
Ungolfed:
#include <iostream>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/multiprecision/miller_rabin.hpp>
using namespace boost::random;
typedef boost::multiprecision::cpp_int integer;
int main( int argc, char** argv )
{
mt19937 mt( clock() );
independent_bits_engine <mt11213b, 256, integer> rng( mt );
integer input {argv[ 1 ]};
integer possible;
while (possible++ <= input)
if (
// is_prime( possible )
miller_rabin_test( possible, 25, rng )
&&
// possible has "666" in it
(possible.convert_to <std::string> ().find( "666" ) != std::string::npos))
std::cout << possible << " ";
}
यादृच्छिक संख्या परीक्षण के संदर्भ में शॉर्टकट बनाए गए थे। मूल कोड ने 6661 पर संभावित अपराधों का परीक्षण शुरू किया और दो द्वारा बढ़ाया गया। आपको उस समय (-1) की वजह से एक कंपाइलर की चेतावनी भी मिलेगी।
फिर भी, यह बहुत जल्दी चलता है। मेरे पुराने AMD Sempron 130 पर 1,000,000 से कम 214 शैतानी प्राइम खोजने में केवल 40 सेकंड का समय लगा।
: ^ डी
output the nth satan primeचुनौती ...