Created
October 8, 2014 13:52
-
-
Save orian/4324c725c2d89ad0e600 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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