RosettaCodeData/Task/List-comprehensions/Rust/list-comprehensions-6.rs
2024-10-16 18:07:41 -07:00

9 lines
205 B
Rust

fn pyth(n: u32) -> impl Iterator<Item = [u32; 3]> {
comp!(
[x, y, z],
for x in 1..=n,
for y in x..=n,
for z in y..=n,
if x.pow(2) + y.pow(2) == z.pow(2)
)
}