23:39:56> for(i=3,65,if(!isprime(3018245755367%i),print(i)))
61
63
64
23:40:08> for(i=3,65,if(!isprime(3881604836567%i),print(i)))
61
63
65
23:40:22> for(i=3,65,if(!isprime(7985415341207%i),print(i)))
63
65
23:40:31> for(i=3,65,if(!isprime(8349851234567%i),print(i)))
63
用60测得的4个结果,最小的3018245755367会在61失效,而直到n=62,7985415341207依旧可用
算这个……- real 0m2.583suser 0m24.142ssys 0m0.076s
复制代码 Rust是个好程序
预计算是个好算法- #![feature(const_int_pow)]const ISPRIME:[bool;201]=[false, false, true, true, false, true, false, true, false, false, false, true, false, true, false, false, false, true, false, true, false, false, false, true, false, false, false, false, false, true, false, true, false, false, false, false, false, true, false, false, false, true, false, true, false, false, false, true, false, false, false, false, false, true, false, false, false, false, false, true, false, true, false, false, false, false, false, true, false, false, false, true, false, true, false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, true, false, false, false, false, false, false, false, true, false, false, false, true, false, true, false, false, false, true, false, true, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, true, false, true, false, false, false, false, false, false, false, false, false, true, false, true, false, false, false, false, false, true, false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, true, false, false, false, false, false, true, false, true, false, false, false, false, false, false, false, false, false, true, false, true, false, false, false, true, false, true, false];const UPPER:usize=60;extern crate rayon;use rayon::prelude::*;fn main(){ let b=search_pre(); search_after(&b);}const LENGTH:usize=2usize.pow(5)*3usize.pow(3)*5usize.pow(2)*7usize.pow(2);fn search_pre()->Vec<usize>{ let mut b:Vec<_>=(1..=LENGTH).collect(); for t in 3..=UPPER{ if LENGTH%t==0{ for i in (0..b.len()).rev(){ if !ISPRIME[b[i]%t]{b.swap_remove(i);} } } } b.sort_unstable(); b}fn search_after(b:&[usize]){ (0..8000000usize).into_par_iter().for_each(|x|{ for i in b.into_iter().map(|c|c+x*LENGTH){ if (3..=UPPER).all(|t|ISPRIME[i%t]){ println!("found n={}!",i) } } })}
复制代码 下面可以放心地从搜索63开始了
Update:63的结果:
found n=2!
found n=5117373107443396802!
found n=5469140162292206402!
found n=4561419428803036802!
found n=12698992845016077602!
found n=15055225617580948802!
found n=3364025168209305602!
found n=1479414399394932002!
62的时候最小值是7985415341207
63的时候最小值是1479414399394932002
害怕……
PS.n>=63时,数字mod1010824870255200的结果只能是2,288807105787202,577614211574402
这里1010824870255200是CRT算出来的
把Rust改成u128之后算得- 00:45:21> for(i=3,90,if(!isprime(195797066175538027202%i),print(i);break))7900:45:38> for(i=3,90,if(!isprime(616072054588129339202%i),print(i);break))81
复制代码 Rust主程序如下- #![feature(const_int_pow)]const ISPRIME:[bool;201]=[false, false, true, true, false, true, false, true, false, false, false, true, false, true, false, false, false, true, false, true, false, false, false, true, false, false, false, false, false, true, false, true, false, false, false, false, false, true, false, false, false, true, false, true, false, false, false, true, false, false, false, false, false, true, false, false, false, false, false, true, false, true, false, false, false, false, false, true, false, false, false, true, false, true, false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, true, false, false, false, false, false, false, false, true, false, false, false, true, false, true, false, false, false, true, false, true, false, false, false, true, false, false, false, false, false, false, false, false, false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, true, false, true, false, false, false, false, false, false, false, false, false, true, false, true, false, false, false, false, false, true, false, false, false, false, false, true, false, false, false, true, false, false, false, false, false, true, false, false, false, false, false, true, false, true, false, false, false, false, false, false, false, false, false, true, false, true, false, false, false, true, false, true, false];const UPPER:usize=74;const LENGTH:u128=if UPPER>=63 {1010824870255200} else{2usize.pow(5)*3usize.pow(3)*5usize.pow(2)*7usize.pow(2)} as u128;extern crate rayon;use rayon::prelude::*;fn main(){ let b=if UPPER<63{ search_pre() }else{ search_pre_ge63() }; search_after(&b);}fn search_pre()->Vec<u128>{ dbg!(LENGTH); let mut b:Vec<_>=(1..=LENGTH).collect(); for t in 3..=UPPER as u128{ if LENGTH%t==0{ for i in (0..b.len()).rev(){ if !ISPRIME[(b[i]%t) as usize]{b.swap_remove(i);} } } } b.sort_unstable(); dbg!(b)}fn search_pre_ge63()->Vec<u128>{ assert!(LENGTH==1010824870255200); vec![2,288807105787202,577614211574402]}fn search_after(b:&[u128]){ (0..3193600u128).into_par_iter().for_each(|x|{ for i in b.into_iter().map(|c|c+x*LENGTH){ if (3..=UPPER).all(|t|ISPRIME[(i%t as u128) as usize]){ println!("found n={}!",i) } } })}
复制代码 Update,如果我的搜索没错(多半有BUG……)
n=63时,每rep=591133442051411133755680800个数中有294053760个数符合题意 |