Created
October 8, 2014 13:59
-
-
Save orian/e062b694816454f3bee3 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(a, b int) int { | |
var w int | |
for w == 0 { | |
if a > b { | |
a = a - b | |
} else { | |
if b > a { | |
b = b - a | |
} else { | |
if a == b { | |
w = a | |
return w | |
} | |
} | |
} | |
} | |
return w | |
} | |
func main() { | |
var a, b 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