Sort by

recency

|

3081 Discussions

|

  • + 0 comments

    Find one or more numbers x, y , z etc.. such that for x, a is a factor of x (GCD) b is a multiple of x

    We need to check the numbers in the range from max(a) to min(b).
    Loop through this range of integers and check numbers in 'a' divide the number without remainders. Also check x divides numbers in 'b' without remainders.

  • + 0 comments

    Python Code:

    def lcm(x, y): return x * y // math.gcd(x, y)

    def getTotalX(a, b): # Find LCM of all numbers in a l = a[0] for i in range(1, len(a)): l = lcm(l, a[i])

    # Find GCD of all numbers in b
    g = b[0]
    for i in range(1, len(b)):
        g = math.gcd(g, b[i])
    
    # Count numbers between sets
    count = 0
    for i in range(l, g + 1, l):
        if g % i == 0:
            count += 1
    return count
    
  • + 0 comments

    lol php sometimes feels like it’s trolling you one extra curly and whole logic collapse. the math behind “between two sets” is clean, but code always messy if braces dance wrong. truth is: computers not forgiving, but that’s what makes finding the perfect bracket balance kinda zen.

  • + 0 comments

    the resolute in php function getTotalX(b) { a; sort(sb = sb); sb); i=1;mb;count); } function isperfect (a){ foreach(i => Extra close brace or missing open bracej,Extra open brace or missing close braceb as val){ if(j != 0 ){ return false; } } return true; }

  • + 0 comments

    Code in C#

    int count = 0; List factorsOfAarray = new(); int minimumb = b.Min(); for (int i = a.Max(); i <= minimumb; i++) { bool remainderOperator = true; foreach (var element in b) { if (element % i != 0) { remainderOperator = false; } } if (remainderOperator) { bool factorsOfinteger = true; foreach (var elementina in a) { if (i % elementina != 0) { factorsOfinteger = false; } } if (factorsOfinteger) { count += 1; } } }

    Console.WriteLine(count)