From e794020d8b881ede726338be50eaa461a134889f Mon Sep 17 00:00:00 2001 From: Charles Cabergs Date: Sun, 20 Jun 2021 20:10:05 +0200 Subject: Refactoging julia problems with function chainning --- julia/009-special_pythagorean_triplet.jl | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) (limited to 'julia/009-special_pythagorean_triplet.jl') diff --git a/julia/009-special_pythagorean_triplet.jl b/julia/009-special_pythagorean_triplet.jl index 65404be..6723e66 100644 --- a/julia/009-special_pythagorean_triplet.jl +++ b/julia/009-special_pythagorean_triplet.jl @@ -13,14 +13,10 @@ using Base.Iterators -for c in countfrom(1) - for b in 1:(c - 1) - for a in 1:(b - 1) - if a ^ 2 + b ^ 2 == c ^ 2 && a + b + c == 1000 - println(a * b * c) - exit(0) - end - end +for c in countfrom(1), b in 1:(c - 1), a in 1:(b - 1) + if a ^ 2 + b ^ 2 == c ^ 2 && a + b + c == 1000 + println(a * b * c) + break end end -- cgit