Last active
August 29, 2015 14:13
-
-
Save gustafsson/b44201cbc8336618534a to your computer and use it in GitHub Desktop.
Number of numeric palindromes in different bases
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% Number of numeric palindromes in different bases | |
N = zeros(4096,36); | |
for i=2:size(N,1) | |
N(i,:) = N(i-1,:); | |
for b=2:size(N,2) | |
s = dec2base(i,b); | |
if all(s == fliplr(s)) | |
N(i,b) = N(i,b) + 1; | |
end | |
end | |
end | |
loglog(N(:,2:36)) | |
legend(arrayfun(@num2str, 2:36, 'UniformOutput', false), 'Location', 'best'); | |
print('-dpng','palindromes.png') | |
disp('N = 2015') | |
[2:36;N(2015,2:end)]' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
N = 2015 | |
2 92 | |
3 99 | |
4 92 | |
5 103 | |
6 89 | |
7 87 | |
8 92 | |
9 103 | |
10 118 | |
11 135 | |
12 155 | |
13 165 | |
14 155 | |
15 146 | |
16 139 | |
17 133 | |
18 127 | |
19 122 | |
20 118 | |
21 114 | |
22 111 | |
23 108 | |
24 105 | |
25 103 | |
26 101 | |
27 99 | |
28 97 | |
29 96 | |
30 95 | |
31 93 | |
32 92 | |
33 92 | |
34 91 | |
35 90 | |
36 89 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment