Rhonda numbers: Difference between revisions

Added Rust solution
(Added Rust solution)
Line 1,116:
In base 10: 1000, 4800, 5670, 8190, 10998, 12412, 13300, 15750, 16821, 23016, 51612, 52734, 67744, 70929, 75030
In base 36: RS, 3PC, 4DI, 6BI, 8HI, 9KS, A9G, C5I, CZ9, HRC, 13TO, 14OU, 1G9S, 1IQ9, 1LW6</pre>
 
=={{header|Rust}}==
<lang rust>// [dependencies]
// radix_fmt = "1.0"
 
fn digit_product(base: u32, mut n: u32) -> u32 {
let mut product = 1;
while n != 0 {
product *= n % base;
n /= base;
}
product
}
 
fn prime_factor_sum(mut n: u32) -> u32 {
let mut sum = 0;
while (n & 1) == 0 {
sum += 2;
n >>= 1;
}
let mut p = 3;
while p * p <= n {
while n % p == 0 {
sum += p;
n /= p;
}
p += 2;
}
if n > 1 {
sum += n;
}
sum
}
 
fn is_prime(n: u32) -> bool {
if n < 2 {
return false;
}
if n % 2 == 0 {
return n == 2;
}
if n % 3 == 0 {
return n == 3;
}
let mut p = 5;
while p * p <= n {
if n % p == 0 {
return false;
}
p += 2;
if n % p == 0 {
return false;
}
p += 4;
}
true
}
 
fn is_rhonda(base: u32, n: u32) -> bool {
digit_product(base, n) == base * prime_factor_sum(n)
}
 
fn main() {
let limit = 15;
for base in 2..=36 {
if is_prime(base) {
continue;
}
println!("First {} Rhonda numbers to base {}:", limit, base);
let numbers: Vec<u32> = (1..).filter(|x| is_rhonda(base, *x)).take(limit).collect();
print!("In base 10:");
for n in &numbers {
print!(" {}", n);
}
print!("\nIn base {}:", base);
for n in &numbers {
print!(" {}", radix_fmt::radix(*n, base as u8));
}
print!("\n\n");
}
}</lang>
 
{{out}}
<pre>
First 15 Rhonda numbers to base 4:
In base 10: 10206 11935 12150 16031 45030 94185 113022 114415 191149 244713 259753 374782 392121 503773 649902
In base 4: 2133132 2322133 2331312 3322133 22333212 112333221 123211332 123323233 232222231 323233221 333122221 1123133332 1133232321 1322333131 2132222232
 
First 15 Rhonda numbers to base 6:
In base 10: 855 1029 3813 5577 7040 7304 15104 19136 35350 36992 41031 42009 60368 65536 67821
In base 6: 3543 4433 25353 41453 52332 53452 153532 224332 431354 443132 513543 522253 1143252 1223224 1241553
 
First 15 Rhonda numbers to base 8:
In base 10: 1836 6318 6622 10530 14500 14739 17655 18550 25398 25956 30562 39215 39325 50875 51429
In base 8: 3454 14256 14736 24442 34244 34623 42367 44166 61466 62544 73542 114457 114635 143273 144345
 
First 15 Rhonda numbers to base 9:
In base 10: 15540 21054 25331 44360 44660 44733 47652 50560 54944 76857 77142 83334 83694 96448 97944
In base 9: 23276 31783 37665 66758 67232 67323 72326 76317 83328 126376 126733 136273 136723 156264 158316
 
First 15 Rhonda numbers to base 10:
In base 10: 1568 2835 4752 5265 5439 5664 5824 5832 8526 12985 15625 15698 19435 25284 25662
In base 10: 1568 2835 4752 5265 5439 5664 5824 5832 8526 12985 15625 15698 19435 25284 25662
 
First 15 Rhonda numbers to base 12:
In base 10: 560 800 3993 4425 4602 4888 7315 8296 9315 11849 12028 13034 14828 15052 16264
In base 12: 3a8 568 2389 2689 27b6 29b4 4297 4974 5483 6a35 6b64 7662 86b8 8864 94b4
 
First 15 Rhonda numbers to base 14:
In base 10: 11475 18655 20565 29631 31725 45387 58404 58667 59950 63945 67525 68904 91245 99603 125543
In base 14: 4279 6b27 76cd ab27 b7c1 1277d 173da 17547 17bc2 19437 1a873 1b17a 25377 28427 33a75
 
First 15 Rhonda numbers to base 15:
In base 10: 2392 2472 11468 15873 17424 18126 19152 20079 24388 30758 31150 33004 33550 37925 39483
In base 15: a97 aec 35e8 4a83 5269 5586 5a1c 5e39 735d 91a8 936a 9ba4 9e1a b385 ba73
 
First 15 Rhonda numbers to base 16:
In base 10: 1000 1134 6776 15912 19624 20043 20355 23946 26296 29070 31906 32292 34236 34521 36465
In base 16: 3e8 46e 1a78 3e28 4ca8 4e4b 4f83 5d8a 66b8 718e 7ca2 7e24 85bc 86d9 8e71
 
First 15 Rhonda numbers to base 18:
In base 10: 1470 3000 8918 17025 19402 20650 21120 22156 26522 36549 38354 43281 46035 48768 54229
In base 18: 49c 94c 1998 2g9f 35fg 39d4 3b36 3e6g 49f8 64e9 6a6e 77a9 7g19 8696 956d
 
First 15 Rhonda numbers to base 20:
In base 10: 1815 11050 15295 21165 22165 30702 34510 34645 42292 44165 52059 53416 65945 78430 80712
In base 20: 4af 17ca 1i4f 2ci5 2f85 3gf2 465a 46c5 55ec 5a85 6a2j 6dag 84h5 9g1a a1fc
 
First 15 Rhonda numbers to base 21:
In base 10: 1632 5390 8512 12992 15678 25038 29412 34017 39552 48895 49147 61376 85078 89590 91798
In base 21: 3ef c4e j67 189e 1ebc 2eg6 33ec 3e2i 45e9 55i7 5697 6d3e 93j7 9e34 9j37
 
First 15 Rhonda numbers to base 22:
In base 10: 2695 4128 7865 28800 31710 37030 71875 74306 117760 117895 121626 126002 131427 175065 192753
In base 22: 5cb 8be g5b 2fb2 2lb8 3ab4 6gb1 6lbc b16g b1cj b96a bi78 c7bl g9fb i25b
 
First 15 Rhonda numbers to base 24:
In base 10: 2080 2709 3976 5628 5656 7144 8296 9030 10094 17612 20559 24616 26224 29106 31458
In base 24: 3eg 4gl 6lg 9ic 9jg c9g e9g fg6 hce 16dk 1bgf 1ihg 1lcg 22ci 26ei
 
First 15 Rhonda numbers to base 25:
In base 10: 6764 9633 13260 22022 53382 57640 66015 69006 97014 140130 142880 144235 159724 162565 165504
In base 25: ake fa8 l5a 1a5m 3aa7 3h5f 45ff 4aa6 655e 8o55 93f5 95ja a5do aa2f aek4
 
First 15 Rhonda numbers to base 26:
In base 10: 7788 9322 9374 11160 22165 27885 34905 44785 47385 49257 62517 72709 74217 108745 132302
In base 26: bde dke dme gd6 16kd 1f6d 1pgd 2e6d 2i2d 2kmd 3ecd 43ed 45kd 64md 7die
 
First 15 Rhonda numbers to base 27:
In base 10: 4797 11844 12078 13200 14841 17750 24320 26883 27477 46455 52750 58581 61009 61446 61500
In base 27: 6fi g6i gf9 i2o k9i o9b 169k 19ni 1aii 29jf 2i9j 2q9i 32ig 337l 339l
 
First 15 Rhonda numbers to base 28:
In base 10: 3094 5808 5832 7462 11160 13671 27270 28194 28638 39375 39550 49500 50862 52338 52938
In base 28: 3qe 7bc 7c8 9ee e6g hc7 16lq 17qq 18em 1m67 1mce 273o 28oe 2al6 2bei
 
First 15 Rhonda numbers to base 30:
In base 10: 3024 3168 5115 5346 5950 6762 7750 7956 8470 9476 9576 9849 10360 11495 13035
In base 30: 3ao 3fi 5kf 5s6 6ia 7fc 8ia 8p6 9ca afq aj6 as9 bfa cn5 eef
 
First 15 Rhonda numbers to base 32:
In base 10: 1944 3600 13520 15876 16732 16849 25410 25752 28951 47472 49610 50968 61596 64904 74005
In base 32: 1so 3gg d6g fg4 gas geh oq2 p4o s8n 1ebg 1gea 1hoo 1s4s 1vc8 288l
 
First 15 Rhonda numbers to base 33:
In base 10: 756 7040 7568 13826 24930 30613 59345 63555 64372 131427 227840 264044 313709 336385 344858
In base 33: mu 6fb 6vb cmw mtf s3m 1lgb 1pbu 1q3m 3lml 6b78 7bfb 8o2b 9btg 9jm8
 
First 15 Rhonda numbers to base 34:
In base 10: 5661 14161 15620 16473 22185 37145 125579 134692 135405 138472 140369 177086 250665 255552 295614
In base 34: 4uh c8h dhe e8h j6h w4h 36lh 3ehi 3f4h 3hqo 3jeh 4h6e 6csh 6h28 7hoi
 
First 15 Rhonda numbers to base 35:
In base 10: 8232 9476 9633 18634 30954 41905 52215 52440 56889 61992 62146 66339 98260 102180 103305
In base 35: 6p7 7pq 7u8 f7e p9e y7a 17lu 17sa 1bfe 1fl7 1fpl 1j5e 2a7f 2def 2ebk
 
First 15 Rhonda numbers to base 36:
In base 10: 1000 4800 5670 8190 10998 12412 13300 15750 16821 23016 51612 52734 67744 70929 75030
In base 36: rs 3pc 4di 6bi 8hi 9ks a9g c5i cz9 hrc 13to 14ou 1g9s 1iq9 1lw6
 
</pre>
 
=={{header|Sidef}}==
1,777

edits