Search Options

Results per page
Sort
Preferred Languages
Advance

Results 1 - 10 of 38 for Gcd (0.02 sec)

  1. src/cmd/go/testdata/script/cover_swig.txt

    /* Compute the greatest common divisor of positive integers */
    int gcd(int x, int y) {
      int g;
      g = y;
      while (x > 0) {
        g = x;
        x = y % x;
        y = g;
      }
      return g;
    }
    
    
    -- main.go --
    package main
    
    import (
    	"fmt"
    )
    
    func main() {
    	// Call our gcd() function
    	x := 42
    	y := 105
    	g := Gcd(x, y)
    	fmt.Println("The gcd of", x, "and", y, "is", g)
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Fri Jan 05 21:29:51 UTC 2024
    - 1.1K bytes
    - Viewed (0)
  2. src/math/big/alias_test.go

    			}, v.Int, y.Int, z.Int)
    		},
    		"GCD": func(v, x, y bigInt) bool {
    			return checkAliasingTwoArgs(t, func(v, x, y *big.Int) *big.Int {
    				return v.GCD(nil, nil, x, y)
    			}, v.Int, x.Int, y.Int)
    		},
    		"GCD-X": func(v, x, y bigInt) bool {
    			a, b := new(big.Int), new(big.Int)
    			return checkAliasingTwoArgs(t, func(v, x, y *big.Int) *big.Int {
    				a.GCD(v, b, x, y)
    				return v
    			}, v.Int, x.Int, y.Int)
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 19 15:49:05 UTC 2022
    - 8.8K bytes
    - Viewed (0)
  3. src/math/big/int_test.go

    	}
    	var Y *Int
    	if y != nil {
    		Y = new(Int)
    	}
    
    	D := new(Int).GCD(X, Y, a, b)
    	if D.Cmp(d) != 0 {
    		t.Errorf("GCD(%s, %s, %s, %s): got d = %s, want %s", x, y, a, b, D, d)
    	}
    	if x != nil && X.Cmp(x) != 0 {
    		t.Errorf("GCD(%s, %s, %s, %s): got x = %s, want %s", x, y, a, b, X, x)
    	}
    	if y != nil && Y.Cmp(y) != 0 {
    		t.Errorf("GCD(%s, %s, %s, %s): got y = %s, want %s", x, y, a, b, Y, y)
    	}
    
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Thu May 23 18:42:28 UTC 2024
    - 58.5K bytes
    - Viewed (0)
  4. src/math/big/gcd_test.go

    // Copyright 2012 The Go Authors. All rights reserved.
    // Use of this source code is governed by a BSD-style
    // license that can be found in the LICENSE file.
    
    // This file implements a GCD benchmark.
    // Usage: go test math/big -test.bench GCD
    
    package big
    
    import (
    	"math/rand"
    	"testing"
    )
    
    // randInt returns a pseudo-random Int in the range [1<<(size-1), (1<<size) - 1]
    func randInt(r *rand.Rand, size uint) *Int {
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Sep 14 19:11:43 UTC 2016
    - 2.2K bytes
    - Viewed (0)
  5. android/guava/src/com/google/common/math/IntMath.java

        int bTwos = Integer.numberOfTrailingZeros(b);
        b >>= bTwos; // divide out all 2s
        while (a != b) { // both a, b are odd
          // The key to the binary GCD algorithm is as follows:
          // Both a and b are odd. Assume a > b; then gcd(a - b, b) = gcd(a, b).
          // But in gcd(a - b, b), a - b is even and b is odd, so we can divide out powers of two.
    
          // We bend over backwards to avoid branching, adapting a technique from
    Registered: Wed Jun 12 16:38:11 UTC 2024
    - Last Modified: Wed Feb 07 17:50:39 UTC 2024
    - 23.5K bytes
    - Viewed (0)
  6. android/guava-tests/test/com/google/common/math/IntMathTest.java

          for (int b : POSITIVE_INTEGER_CANDIDATES) {
            assertEquals(valueOf(a).gcd(valueOf(b)), valueOf(IntMath.gcd(a, b)));
          }
        }
      }
    
      public void testGCDZero() {
        for (int a : POSITIVE_INTEGER_CANDIDATES) {
          assertEquals(a, IntMath.gcd(a, 0));
          assertEquals(a, IntMath.gcd(0, a));
        }
        assertEquals(0, IntMath.gcd(0, 0));
      }
    
      public void testGCDNegativePositiveThrows() {
    Registered: Wed Jun 12 16:38:11 UTC 2024
    - Last Modified: Wed Feb 07 17:50:39 UTC 2024
    - 24.5K bytes
    - Viewed (0)
  7. docs/distributed/DESIGN.md

    1024 drives. In this scenario 16 becomes the erasure set size. This is decided based on the greatest common divisor (GCD) of acceptable erasure set sizes ranging from *4 to 16*.
    
    - *If total drives has many common divisors the algorithm chooses the minimum amounts of erasure sets possible for a erasure set size of any N*.  In the example with 1024 drives - 4, 8, 16 are GCD factors. With 16 drives we get a total of 64 possible sets, with 8 drives we get a total of 128 possible sets, with 4...
    Registered: Sun Jun 16 00:44:34 UTC 2024
    - Last Modified: Tue Aug 15 23:04:20 UTC 2023
    - 8K bytes
    - Viewed (0)
  8. test/chan/powser1.go

    // Input variables: U,V,...
    // Output variables: ...,Y,Z
    
    // Integer gcd; needed for rational arithmetic
    
    func gcd(u, v int64) int64 {
    	if u < 0 {
    		return gcd(-u, v)
    	}
    	if u == 0 {
    		return v
    	}
    	return gcd(v%u, u)
    }
    
    // Make a rational from two ints and from one int
    
    func i2tor(u, v int64) rat {
    	g := gcd(u, v)
    	var r rat
    	if v > 0 {
    		r.num = u / g
    		r.den = v / g
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Mar 25 22:22:20 UTC 2020
    - 12.7K bytes
    - Viewed (0)
  9. android/guava-tests/test/com/google/common/math/LongMathTest.java

            assertEquals(valueOf(a).gcd(valueOf(b)), valueOf(LongMath.gcd(a, b)));
          }
        }
      }
    
      @GwtIncompatible // TODO
      public void testGCDZero() {
        for (long a : POSITIVE_LONG_CANDIDATES) {
          assertEquals(a, LongMath.gcd(a, 0));
          assertEquals(a, LongMath.gcd(0, a));
        }
        assertEquals(0, LongMath.gcd(0, 0));
      }
    
      @GwtIncompatible // TODO
    Registered: Wed Jun 12 16:38:11 UTC 2024
    - Last Modified: Mon Mar 04 20:15:57 UTC 2024
    - 32.5K bytes
    - Viewed (0)
  10. test/chan/powser2.go

    // Input variables: U,V,...
    // Output variables: ...,Y,Z
    
    // Integer gcd; needed for rational arithmetic
    
    func gcd(u, v int64) int64 {
    	if u < 0 {
    		return gcd(-u, v)
    	}
    	if u == 0 {
    		return v
    	}
    	return gcd(v%u, u)
    }
    
    // Make a rational from two ints and from one int
    
    func i2tor(u, v int64) *rat {
    	g := gcd(u, v)
    	r := new(rat)
    	if v > 0 {
    		r.num = u / g
    		r.den = v / g
    Registered: Wed Jun 12 16:32:35 UTC 2024
    - Last Modified: Wed Mar 25 22:22:20 UTC 2020
    - 13.3K bytes
    - Viewed (0)
Back to top