Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 4^n = m
- n = 4 3 2 1 0
- m = 256 64 16 4 1
- numbers: 15,39,63,157,255,1023
- 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.
- Edit: I wrote an implementation in python: http://pastebin.com/fp5ApbeS
- 15
- 15 < 256
- 0
- 15 < 64
- 00
- 15 < 16
- 000
- 15 >= 4
- 15-4 = 11
- 0001
- 11-4 = 7
- 0002
- 7-4 = 3
- 0003
- 3 < 4
- 3 >= 1
- 3-1 = 2
- 00031
- 2-1 = 1
- 00032
- 1-1 = 0
- >>> 00033
- 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)
- 39
- 00
- 39-16 = 23
- 001
- 23-16 = 7
- 002
- 7-4 = 3
- 0021
- 3-1 = 2
- 00211
- 2-1 = 1
- 00212
- 1-1 = 0
- 00213
- 63
- 63 = (4^3)-1 = 00333
- 157
- 0
- 157-64 = 93
- 01
- 93-64 = 29
- 02
- 29-16 = 13
- 021
- 13-4 = 9
- 0211
- 9-4 = 5
- 0212
- 5-4 = 1
- 0213
- 1-1 = 0
- 02131
- 255
- 255 = (4^4)-1 = 03333
- 1023
- 1023 = (4^5)-1 = 33333
- 15 = 00033
- 39 = 00213
- 63 = 00333
- 157 = 02131
- 255 = 03333
- 1023 = 33333
- 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...
- >>> 39 * 4 + 1
- 157
- >>> 63 * 4 + 3
- 255
- 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