Colorful numbers: Difference between revisions
Content added Content deleted
m (→{{header|Rust}}: formatting) |
|||
Line 2,195: | Line 2,195: | ||
fn is_colorful(n: u64) -> bool { |
fn is_colorful(n: u64) -> bool { |
||
if &n > & |
if &n > &9 { |
||
let dig: Vec<u64> = to_digits(n, 10); |
let dig: Vec<u64> = to_digits(n, 10); |
||
if dig.contains(&1) || dig.contains(&0) { |
if dig.contains(&1) || dig.contains(&0) { |
||
Line 2,236: | Line 2,236: | ||
let mut n: u64; |
let mut n: u64; |
||
for i in 0..8 { |
for i in 0..8 { |
||
let j: u64 = { if i == 0 { 0 } else { 10_u64.pow(i) |
let j: u64 = { if i == 0 { 0 } else { 10_u64.pow(i) } }; |
||
let k: u64 = 10_u64.pow(i + 1) - 1; |
let k: u64 = 10_u64.pow(i + 1) - 1; |
||
n = 0; |
n = 0; |
||
Line 2,254: | Line 2,254: | ||
<pre> |
<pre> |
||
Colorful numbers for 1:25, 26:50, 51:75, and 76:100: |
Colorful numbers for 1:25, 26:50, 51:75, and 76:100: |
||
1 2 3 4 5 6 7 8 9 |
1 2 3 4 5 6 7 8 9 23 24 25 |
||
26 27 28 29 32 34 35 36 37 38 39 42 43 45 46 47 48 49 |
26 27 28 29 32 34 35 36 37 38 39 42 43 45 46 47 48 49 |
||
52 53 54 56 57 58 59 62 63 64 65 67 68 69 72 73 74 75 |
52 53 54 56 57 58 59 62 63 64 65 67 68 69 72 73 74 75 |
||
76 78 79 82 83 84 85 86 87 89 92 93 94 95 96 97 98 |
76 78 79 82 83 84 85 86 87 89 92 93 94 95 96 97 98 |
||
The count of colorful numbers within the interval |
The count of colorful numbers within the interval [0, 9] is 10. |
||
The count of colorful numbers within the interval |
The count of colorful numbers within the interval [10, 99] is 56. |
||
The count of colorful numbers within the interval |
The count of colorful numbers within the interval [100, 999] is 328. |
||
The count of colorful numbers within the interval |
The count of colorful numbers within the interval [1000, 9999] is 1540. |
||
The count of colorful numbers within the interval |
The count of colorful numbers within the interval [10000, 99999] is 5514. |
||
The count of colorful numbers within the interval |
The count of colorful numbers within the interval [100000, 999999] is 13956. |
||
The count of colorful numbers within the interval |
The count of colorful numbers within the interval [1000000, 9999999] is 21596. |
||
The largest possible colorful number is 98746253. |
The largest possible colorful number is 98746253. |
||
The total number of colorful numbers is 57256. |
The total number of colorful numbers is 57256. |