Permalink
Browse files

Use C's printf in simple.rs to provide a fair comparison.

  • Loading branch information...
boxdot committed Dec 31, 2018
1 parent 0e35194 commit f0a6e873001751690b6912ece52156e3007e66e5
Showing with 8 additions and 5 deletions.
  1. +8 −5 simple.rs
@@ -1,15 +1,18 @@
extern "C" {
fn printf(fmt: *const i8, ...) -> i32;
}

pub fn main() {
print_triples();
}


fn print_triples() {
let mut i = 0 as i32;
for z in 1.. {
for x in 1..=z {
for y in x..=z {
if x*x + y*y == z*z {
println!("({}, {}, {})", x, y, z);
for x in 1..z + 1 {
for y in x..z + 1 {
if x * x + y * y == z * z {
unsafe { printf("(%i, %i, %i)\n".as_ptr() as *const i8, x, y, z) };
i = i + 1;
if i == 1000 {
return;

0 comments on commit f0a6e87

Please sign in to comment.