资源描述:
《奇数等速螺旋图程序vba源码》由会员上传分享,免费在线阅读,更多相关内容在工程资料-天天文库。
1、AUTOCADvba素数等速螺旋散点图程序代码本程序仅对奇数筛选,偶数已经排除,运行需要大于10几分钟,运行时不要做其他操作,否则电脑可能死机,素数筛选需要人量计算。图形是410821个奇数散点图,程序可以筛选913万内素数,但是不是超级计算机不要点改变集合Dimp(lTo200000)AsDouble内的20万,及i的取值,图中红色为素数点,蓝色为合数点。合计奇数素数65535,2排除在外,1被标记为红色可以代表2,总计65536个素数红点,图像小心部位三条旋转背,…条蓝色为纯合数线,其他两条为混合数线,其中红点为素数,此程序为最优排列筛选。
2、如果把k值乘以2即以上的整数,则所有数均排列到一条旋转背上。Sub素数螺旋()DimtAsVariantDimnAsVariantDimcoAsVariantDimSAsVariantDimkAsVariantDimpointObjAsAcadPointDimlocation(()To2)AsDoubleDimp(0To821641)AsDoubleDimiAsVariantDimJAsVariants=ok=8.8624554903079E-06Fori=0To410820Step1t=2*i+l:S=Sa=ilocation(O)=30*a
3、*(Cos(a/k)):location(l)=30*a*(Sin(a/k)):location(2)=0#SetpointObj=ThisDrawing.ModelSpace.AddPoint(location)Ifqp(t)=1ThenpointObj.color=acRedEndIfIfqp(t)=0ThenpointObj.color=acBIue:S=S+1EndIfNextiMsgBox”合计,&i-S-2&“个素数!“EndSubFunctionp(mAsVariant,nAsVariant)AsVariantIfn>=mThen
4、P=1EndIfIfm/n=Int(m/n)Andn5、sl9AsLongDims20AsLong,s21AsLong,s22AsLong,s23AsLong,s24AsLong,s25AsLongDims26AsLong,s27AsLong,s28AsLong,s29AsLong,s30AsLong,s31AsLongS=p(m,2)*p(m,3)*p(m,5)*p(m,7)*p(m,11)*p(m,13)*p(m,17)*p(m,19)*p(m,23)*p(m,29)*p(m,31)*p(m,37)*p(m,41)*p(m,43)*p(m,47)*p(m,53)*p(m,59)*p(m,61)*
6、p(m,67)*p(m,71)*p(m,73)*p(m,79)*p(m,83)*p(m,89)*p(m,97)si=p(m,101)*p(m,103)*p(m,107)*p(m,109)*p(m,113)*p(m,127)*p(m,131)*p(m,137)*p(m,139)*p(m,149)*p(m,151)*p(m,157)*p(m,163)*p(m,167)*p(m,173)*p(m,179)*p(m,181)*p(m,191)s2=p(m,193)*p(m,197)*p(m,199)*p(m,211)*p(m,223)*p(m,227)
7、*p(m,229)*p(m,233)*p(m,239)*p(m,241)*p(m,251)*p(m,257)*p(m,263)*p(m,269)*p(m,271)*p(m,277)*p(m,281)*p(m,283)s3=p(m,293)*p(m,307)*p(m,311)*p(m,313)*p(m,317)*p(m,331)*p(m,337)*p(m,347)*p(m,349)*p(m,353)*p(m,359)*p(m,367)*p(m,373)*p(m,379)*p(m,383)*p(m,389)*p(m,397)*p(m,401)s4=
8、p(m,409)*p(m,419)*p(m,421)*p(m,431)*p(m,433)*p(m,439)*p(m,443)*p(m,449)*p(m