Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.87 KB | None | 0 0
  1. {
  2. "cells": [
  3. {
  4. "cell_type": "code",
  5. "execution_count": 5,
  6. "metadata": {
  7. "collapsed": false
  8. },
  9. "outputs": [],
  10. "source": [
  11. "import math\n",
  12. "NUMBER = 100000000\n",
  13. "\n",
  14. "def get_prime_list(limit):\n",
  15. " limit_sqrt = int(math.ceil(math.sqrt(limit)))\n",
  16. " prime_bool_list = [False] * 2 + [True] * (limit - 2)\n",
  17. " for prime_cand in range(2,limit_sqrt):\n",
  18. " if prime_bool_list[prime_cand]:\n",
  19. " for composite in range(prime_cand ** 2, limit, prime_cand):\n",
  20. " prime_bool_list[composite] = False\n",
  21. " return [i for i, b in enumerate(prime_bool_list) if b]\n",
  22. "\n",
  23. "prime_list = get_prime_list(NUMBER)"
  24. ]
  25. },
  26. {
  27. "cell_type": "code",
  28. "execution_count": 6,
  29. "metadata": {
  30. "collapsed": false
  31. },
  32. "outputs": [
  33. {
  34. "name": "stdout",
  35. "output_type": "stream",
  36. "text": [
  37. "1145141\n",
  38. "1145143\n",
  39. "11145143\n",
  40. "11451403\n",
  41. "11451449\n",
  42. "11451467\n",
  43. "11451497\n",
  44. "11451499\n",
  45. "21145141\n",
  46. "31145143\n",
  47. "81145147\n",
  48. "91145149\n"
  49. ]
  50. }
  51. ],
  52. "source": [
  53. "for prime in [str(prime) for prime in prime_list]:\n",
  54. " if \"114514\" in prime:\n",
  55. " print(prime)"
  56. ]
  57. },
  58. {
  59. "cell_type": "code",
  60. "execution_count": null,
  61. "metadata": {
  62. "collapsed": true
  63. },
  64. "outputs": [],
  65. "source": []
  66. }
  67. ],
  68. "metadata": {
  69. "kernelspec": {
  70. "display_name": "IPython (pyenv:3.5.1)",
  71. "language": "python",
  72. "name": "pyenv_3.5.1"
  73. },
  74. "language_info": {
  75. "codemirror_mode": {
  76. "name": "ipython",
  77. "version": 3
  78. },
  79. "file_extension": ".py",
  80. "mimetype": "text/x-python",
  81. "name": "python",
  82. "nbconvert_exporter": "python",
  83. "pygments_lexer": "ipython3",
  84. "version": "3.5.1"
  85. }
  86. },
  87. "nbformat": 4,
  88. "nbformat_minor": 2
  89. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement