Data update
This commit is contained in:
parent
5150844a7d
commit
4bb20c9b71
7735 changed files with 38060 additions and 199180 deletions
|
|
@ -1,21 +0,0 @@
|
|||
with Ada.Text_Io; use Ada.Text_Io;
|
||||
|
||||
procedure Gcd_Test is
|
||||
function Gcd (A, B : Integer) return Integer is
|
||||
M : Integer := A;
|
||||
N : Integer := B;
|
||||
T : Integer;
|
||||
begin
|
||||
while N /= 0 loop
|
||||
T := M;
|
||||
M := N;
|
||||
N := T mod N;
|
||||
end loop;
|
||||
return M;
|
||||
end Gcd;
|
||||
|
||||
begin
|
||||
Put_Line("GCD of 100, 5 is" & Integer'Image(Gcd(100, 5)));
|
||||
Put_Line("GCD of 5, 100 is" & Integer'Image(Gcd(5, 100)));
|
||||
Put_Line("GCD of 7, 23 is" & Integer'Image(Gcd(7, 23)));
|
||||
end Gcd_Test;
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
_GCD(18, 12)
|
||||
_GCD(1071, 1029)
|
||||
_GCD(3528, 3780)
|
||||
|
||||
Func _GCD($ia, $ib)
|
||||
Local $ret = "GCD of " & $ia & " : " & $ib & " = "
|
||||
Local $imod
|
||||
While True
|
||||
$imod = Mod($ia, $ib)
|
||||
If $imod = 0 Then Return ConsoleWrite($ret & $ib & @CRLF)
|
||||
$ia = $ib
|
||||
$ib = $imod
|
||||
WEnd
|
||||
EndFunc ;==>_GCD
|
||||
|
|
@ -1,28 +0,0 @@
|
|||
IDENTIFICATION DIVISION.
|
||||
PROGRAM-ID. GCD.
|
||||
|
||||
DATA DIVISION.
|
||||
WORKING-STORAGE SECTION.
|
||||
01 A PIC 9(10) VALUE ZEROES.
|
||||
01 B PIC 9(10) VALUE ZEROES.
|
||||
01 TEMP PIC 9(10) VALUE ZEROES.
|
||||
|
||||
PROCEDURE DIVISION.
|
||||
Begin.
|
||||
DISPLAY "Enter first number, max 10 digits."
|
||||
ACCEPT A
|
||||
DISPLAY "Enter second number, max 10 digits."
|
||||
ACCEPT B
|
||||
IF A < B
|
||||
MOVE B TO TEMP
|
||||
MOVE A TO B
|
||||
MOVE TEMP TO B
|
||||
END-IF
|
||||
|
||||
PERFORM UNTIL B = 0
|
||||
MOVE A TO TEMP
|
||||
MOVE B TO A
|
||||
DIVIDE TEMP BY B GIVING TEMP REMAINDER B
|
||||
END-PERFORM
|
||||
DISPLAY "The gcd is " A
|
||||
STOP RUN.
|
||||
|
|
@ -20,7 +20,7 @@ printGCD(a,b)
|
|||
Console.printLineFormatted("GCD of {0} and {1} is {2}", a, b, gcd(a,b))
|
||||
}
|
||||
|
||||
public program()
|
||||
public Program()
|
||||
{
|
||||
printGCD(1,1);
|
||||
printGCD(1,10);
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
(defun gcd (a b)
|
||||
(cond
|
||||
((< a b) (gcd a (- b a)))
|
||||
((> a b) (gcd (- a b) b))
|
||||
(t a)))
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
function gcd_iter(integer u, integer v)
|
||||
integer t
|
||||
while v do
|
||||
t = u
|
||||
u = v
|
||||
v = remainder(t, v)
|
||||
end while
|
||||
if u < 0 then
|
||||
return -u
|
||||
else
|
||||
return u
|
||||
end if
|
||||
end function
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
function gcd(integer u, integer v)
|
||||
if v then
|
||||
return gcd(v, remainder(u, v))
|
||||
elsif u < 0 then
|
||||
return -u
|
||||
else
|
||||
return u
|
||||
end if
|
||||
end function
|
||||
|
|
@ -1,40 +0,0 @@
|
|||
function gcd_bin(integer u, integer v)
|
||||
integer t, k
|
||||
if u < 0 then -- abs(u)
|
||||
u = -u
|
||||
end if
|
||||
if v < 0 then -- abs(v)
|
||||
v = -v
|
||||
end if
|
||||
if u < v then
|
||||
t = u
|
||||
u = v
|
||||
v = t
|
||||
end if
|
||||
if v = 0 then
|
||||
return u
|
||||
end if
|
||||
k = 1
|
||||
while and_bits(u,1) = 0 and and_bits(v,1) = 0 do
|
||||
u = floor(u/2) -- u >>= 1
|
||||
v = floor(v/2) -- v >>= 1
|
||||
k *= 2 -- k <<= 1
|
||||
end while
|
||||
if and_bits(u,1) then
|
||||
t = -v
|
||||
else
|
||||
t = u
|
||||
end if
|
||||
while t do
|
||||
while and_bits(t, 1) = 0 do
|
||||
t = floor(t/2)
|
||||
end while
|
||||
if t > 0 then
|
||||
u = t
|
||||
else
|
||||
v = -t
|
||||
end if
|
||||
t = u - v
|
||||
end while
|
||||
return u * k
|
||||
end function
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
function Get-GCD ($x, $y)
|
||||
{
|
||||
if ($x -eq $y) { return $y }
|
||||
if ($x -gt $y) {
|
||||
$a = $x
|
||||
$b = $y
|
||||
}
|
||||
else {
|
||||
$a = $y
|
||||
$b = $x
|
||||
}
|
||||
while ($a % $b -ne 0) {
|
||||
$tmp = $a % $b
|
||||
$a = $b
|
||||
$b = $tmp
|
||||
}
|
||||
return $b
|
||||
}
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
function Get-GCD ($x, $y) {
|
||||
if ($y -eq 0) { $x } else { Get-GCD $y ($x%$y) }
|
||||
}
|
||||
|
|
@ -1,6 +0,0 @@
|
|||
Function Get-GCD( $x, $y ) {
|
||||
while ($y -ne 0) {
|
||||
$x, $y = $y, ($x % $y)
|
||||
}
|
||||
[Math]::abs($x)
|
||||
}
|
||||
|
|
@ -1,14 +0,0 @@
|
|||
gcd: func [
|
||||
{Returns the greatest common divisor of m and n.}
|
||||
m [integer!]
|
||||
n [integer!]
|
||||
/local k
|
||||
] [
|
||||
; Euclid's algorithm
|
||||
while [n > 0] [
|
||||
k: m
|
||||
m: n
|
||||
n: k // m
|
||||
]
|
||||
m
|
||||
]
|
||||
|
|
@ -1 +1 @@
|
|||
⊙◌⍢(⊃∘◿:)(±,)
|
||||
⊙◌⍢(⤙˜◿|◡⋅>₀)
|
||||
|
|
|
|||
|
|
@ -1,17 +0,0 @@
|
|||
Function GCD(a,b)
|
||||
Do
|
||||
If a Mod b > 0 Then
|
||||
c = a Mod b
|
||||
a = b
|
||||
b = c
|
||||
Else
|
||||
GCD = b
|
||||
Exit Do
|
||||
End If
|
||||
Loop
|
||||
End Function
|
||||
|
||||
WScript.Echo "The GCD of 48 and 18 is " & GCD(48,18) & "."
|
||||
WScript.Echo "The GCD of 1280 and 240 is " & GCD(1280,240) & "."
|
||||
WScript.Echo "The GCD of 1280 and 240 is " & GCD(3475689,23566319) & "."
|
||||
WScript.Echo "The GCD of 1280 and 240 is " & GCD(123456789,234736437) & "."
|
||||
Loading…
Add table
Add a link
Reference in a new issue