GCD calculation is an infinite loop #27

Closed
opened 2025-08-28 12:22:30 +00:00 by ed · 1 comment
Owner
import io

main() {
	io.write(gcd(1071, 462))
}

gcd(a int, b int) -> int {
	loop {
		switch {
			a == b { return a }
			a > b  { a -= b }
			_      { b -= a }
		}
	}
}
``` import io main() { io.write(gcd(1071, 462)) } gcd(a int, b int) -> int { loop { switch { a == b { return a } a > b { a -= b } _ { b -= a } } } } ```
ed self-assigned this 2025-08-28 12:22:30 +00:00
Author
Owner

Fixed in cli/q@3bb9a08fae.

Fixed in https://git.urbach.dev/cli/q/commit/3bb9a08fae2510c4df228171e267371047fc2e9d.
ed closed this issue 2025-08-28 19:36:10 +00:00
ed added spent time 2025-08-29 07:47:06 +00:00
6 hours
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Total time spent: 6 hours
ed
6 hours
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
cli/q#27
No description provided.