Super-d numbers: Difference between revisions
Content added Content deleted
(Added C solution) |
m (Rust - performance improvement) |
||
Line 864: | Line 864: | ||
fn print_super_d_numbers(d: u32, limit: u32) { |
fn print_super_d_numbers(d: u32, limit: u32) { |
||
⚫ | |||
use rug::Integer; |
use rug::Integer; |
||
⚫ | |||
println!("First {} super-{} numbers:", limit, d); |
println!("First {} super-{} numbers:", limit, d); |
||
Line 871: | Line 871: | ||
let mut count = 0; |
let mut count = 0; |
||
let mut n = 1; |
let mut n = 1; |
||
let mut s = Integer::new(); |
|||
while count < limit { |
while count < limit { |
||
s.assign(Integer::u_pow_u(n, d)); |
|||
s *= d; |
|||
if s.to_string().contains(&digits) { |
if s.to_string().contains(&digits) { |
||
print!("{} ", n); |
print!("{} ", n); |