Skip to content

Instantly share code, notes, and snippets.

@peace2048
Created April 4, 2014 03:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save peace2048/9967375 to your computer and use it in GitHub Desktop.
Save peace2048/9967375 to your computer and use it in GitHub Desktop.
最大公約数を求める
Module Module1
Sub Main()
' 1000,2500,5000 の最大公約数を求める
Dim n = {1000, 2500, 5000}.Aggregate(AddressOf GDC)
Console.WriteLine(n)
Console.ReadLine()
End Sub
''' <summary>
''' 最大公約数を求める
''' </summary>
Function GDC(a As Integer, b As Integer) As Integer
Dim w As Integer
If a > b Then
w = b
b = a
a = w
End If
While b <> 0
w = a Mod b
a = b
b = w
End While
Return a
End Function
End Module
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment