Advertisement
B1KMusic

Figuring out base 4

Feb 24th, 2015
404
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.46 KB | None | 0 0
  1. 4^n = m
  2. n = 4 3 2 1 0
  3. m = 256 64 16 4 1
  4.  
  5. numbers: 15,39,63,157,255,1023
  6.  
  7. After working through breaking down 15, I figured it out. Keep subtracting 4^n from the number N until N < 4^n. Every time you subtract, add 1 to place value <n>, when N < 4^n, subtract 1 from n, and continue.
  8.  
  9. Edit: I wrote an implementation in python: http://pastebin.com/fp5ApbeS
  10.  
  11. 15
  12. 15 < 256
  13. 0
  14. 15 < 64
  15. 00
  16. 15 < 16
  17. 000
  18. 15 >= 4
  19. 15-4 = 11
  20. 0001
  21. 11-4 = 7
  22. 0002
  23. 7-4 = 3
  24. 0003
  25. 3 < 4
  26. 3 >= 1
  27. 3-1 = 2
  28. 00031
  29. 2-1 = 1
  30. 00032
  31. 1-1 = 0
  32. >>> 00033
  33.  
  34. Or, 15 = 4^2 (100 base 4) - 1 (=33 base 4) => 00033 (which is how I knew 15 in base 4 in the first place)
  35.  
  36. 39
  37. 00
  38. 39-16 = 23
  39. 001
  40. 23-16 = 7
  41. 002
  42. 7-4 = 3
  43. 0021
  44. 3-1 = 2
  45. 00211
  46. 2-1 = 1
  47. 00212
  48. 1-1 = 0
  49. 00213
  50.  
  51. 63
  52. 63 = (4^3)-1 = 00333
  53.  
  54. 157
  55. 0
  56. 157-64 = 93
  57. 01
  58. 93-64 = 29
  59. 02
  60. 29-16 = 13
  61. 021
  62. 13-4 = 9
  63. 0211
  64. 9-4 = 5
  65. 0212
  66. 5-4 = 1
  67. 0213
  68. 1-1 = 0
  69. 02131
  70.  
  71. 255
  72. 255 = (4^4)-1 = 03333
  73.  
  74. 1023
  75. 1023 = (4^5)-1 = 33333
  76.  
  77. 15 = 00033
  78. 39 = 00213
  79. 63 = 00333
  80. 157 = 02131
  81. 255 = 03333
  82. 1023 = 33333
  83.  
  84. Oh, how interesting. 157 (2131) has a very similar base 4 output to 39 (213). This means that 157 should be equal to (39<<1) + 1, or (39 * 4) + 1. And (63 * 4) + 3 should equal 255. Give me a sec to test that...
  85.  
  86. >>> 39 * 4 + 1
  87. 157
  88. >>> 63 * 4 + 3
  89. 255
  90.  
  91. Yep. I love it when models of reality have predictive capability, and those predictions are consistent with reality. The Scientific Method (in this case, Number Theory) wins again.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement