`
ihuashao
  • 浏览: 4547449 次
  • 性别: Icon_minigender_1
  • 来自: 济南
社区版块
存档分类
最新评论

nth prime number contain n as their substring within 100000000

阅读更多

A small VBA code to get these numbers:

  1. SubMain()
  2. Dimi&,j&,k&,n&,num&,a(100000000)AsByte,p(1To10000000)AsLong
  3. num=1
  4. p(num)=2'The1stprime
  5. n=100000000'10^8
  6. k=Int(Sqr(n))'sqrarerootofn
  7. Fori=3TokStep2
  8. Ifa(i)=0Then
  9. num=num+1
  10. p(num)=i
  11. IfInStr(i,num)ThenDebug.Print"P("&num&")="&i
  12. Forj=i*iTonStep2*i'Eractosthenes
  13. a(j)=100'Notprimenumber
  14. Next
  15. EndIf
  16. Next
  17. Fori=k+1TonStep2'Listallprimenumberstoarrayp()
  18. Ifa(i)=0Then
  19. num=num+1
  20. 'p(num)=i
  21. IfInStr(i,num)ThenDebug.Print"P("&num&")="&i
  22. EndIf
  23. Next
  24. EndSub

It returns:

P(7)=17
P(6455)=64553
P(6456)=64567
P(6457)=64577
P(6459)=64591
P(6460)=64601
P(6466)=64661
P(9551)=99551
P(303027)=4303027
P(440999)=6440999
P(968819)=14968819
P(5517973)=95517973

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics