Guest User

Untitled

a guest
Dec 9th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.79 KB | None | 0 0
  1. \documentclass{article}
  2. \usepackage{fancyhdr}
  3. \usepackage{amsmath ,amsthm ,amssymb}
  4. \usepackage{graphicx}
  5. \usepackage{listings}
  6.  
  7. \begin{document}
  8.  
  9. This is slightly cheating because I picked this problem, and I really liked my
  10. approach. I know that this can be solved by brute force, but it's incredibly ugly.
  11.  
  12. First let's define a function $d_k(x)$, that returns the $k$ least significant digits of $x$.
  13.  
  14. \begin{align}
  15. \nonumber
  16. d_1(0)& =0\\
  17. \nonumber
  18. d_1(14)& =4\\
  19. \nonumber
  20. d_2(14)& =14
  21. \end{align}
  22.  
  23. This is really just the $mod$ function is a different form. Just a bit more terse.
  24.  
  25. \[ d_k(x) = x \bmod 10^k \]
  26.  
  27. This function has some identities that are useful for this problem. I won't
  28. prove them.
  29.  
  30. \begin{align}
  31. \label{eq:multid}
  32. d_k(Cx) &= d_k(d_k(C) \cdot d_k(x))\\
  33. \label{eq:addid}
  34. d_k(C + x) &= d_k(d_k(C) + d_k(x))
  35. \end{align}
  36.  
  37. Problem 97 asks us to produce the following:
  38.  
  39. \[
  40. d_{10}(28433 \cdot 2^{7830457} + 1)
  41. \]
  42.  
  43. The identities \eqref{eq:multid} and \eqref{eq:addid} can help us break this
  44. down into something slightly more manageable.
  45.  
  46. \begin{align}
  47. \nonumber
  48. A &= d_{10}(28433 \cdot 2^{7830457} + 1)\\
  49. \nonumber
  50. &= d_{10}(d_{10}(28433) \cdot d_{10}(2^{7830457}) + d_{10}(1))\\
  51. \label{eq:euler97}
  52. &= d_{10}(28433 \cdot d_{10}(2^{7830457}) + 1)
  53. \end{align}
  54.  
  55. $d_{10}(2^{7830457})$ is a waste to compute. Though the identity \eqref{eq:multid} can be used to do some interesting modulus optimizations,
  56. I'd rather find a more elegant solution.
  57.  
  58. Let's look at powers of two in more depth. Consider the powers of 2:
  59.  
  60. \[ 2^x = 1, 2, 4, 8, 16, 32, 64, 128, 256, \ldots \]
  61.  
  62. There is a pattern here when considering just the least signficant digit.
  63.  
  64. \[ d_1(2^x) = 1, 2, 4, 8, 6, 2, 4, 8, 6, \ldots \]
  65.  
  66. This sequence is eventually periodic, with period $4$.
  67.  
  68. \[ P(d_1(2^x)) = 4 \]
  69.  
  70. Using a short Haskell function, I found the periods for the first four digits of $2^x$:
  71.  
  72. \begin{align}
  73. \nonumber
  74. P(d_{1}(2^x)) &= 4\\
  75. \nonumber
  76. P(d_{2}(2^x)) &= 20\\
  77. \nonumber
  78. P(d_{3}(2^x)) &= 100\\
  79. \nonumber
  80. P(d_{4}(2^x)) &= 500
  81. \end{align}
  82.  
  83. The periodicity looked like it could be generalized.
  84.  
  85. \begin{align}
  86. \label{eq:periodicity}
  87. P(d_k(2^x)) &= 4 \cdot 5^{k - 1}\\
  88. \label{eq:specificperiod}
  89. P(d_{10}(2^x)) &= 7812500
  90. \end{align}
  91.  
  92. This number looks promising. Because $d_k(2^x)$ is not strictly periodic, but only eventually periodic, we aren't guaranteed that $d_k(2^x) = d_k(2^{x - P(d_k(2^x))})$. All we can do it just guess and check.
  93.  
  94.  
  95.  
  96. \begin{align}
  97. \nonumber
  98. A &= d_{10}(28433 \cdot d_{10}(2^{7830457}) + 1)\\
  99. \nonumber
  100. &= d_{10}(28433 \cdot d_{10}(2^{7830457 - 7812500}) + 1)\\
  101. \nonumber
  102. &= d_{10}(28433 \cdot d_{10}(2^{17957}) + 1)\\
  103. \label{eq:solution}
  104. &= (28433 \cdot (2^{17957} \bmod 10^{10}) + 1) \bmod 10^{10}
  105. \end{align}
  106.  
  107. This final formula \eqref{eq:solution} is much easier to compute.
  108.  
  109. \end{document}
Add Comment
Please, Sign In to add comment