Skip to content

Instantly share code, notes, and snippets.

@orian
Created Oct 8, 2014
Embed
What would you like to do?
// Projekt6.1.1
package main
import "fmt"
func NWD(A1, B1 int) int {
var W int
for W == 0 {
if A1 > B1 {
A1 = A1 - B1
} else {
if B1 > A1 {
B1 = B1 - A1
} else {
if A1 == B1 {
W = A1
return W
}
}
}
}
return W
}
func main() {
var A, B, W int
fmt.Println("Wpisz A: ")
fmt.Scanf("%d", &A)
fmt.Println("Wpisz B: ")
fmt.Scanf("%d", &B)
W = NWD(A, B)
fmt.Printf("Największy wspólny mianownik liczb %d i %d to %d\n", A, B, W)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment