MCPcopy Create free account
hub / github.com/pgadmin-org/pgadmin4 / getGCD

Function getGCD

web/pgadmin/static/js/utils.js:91–107  ·  view source on GitHub ↗
(inp_arr)

Source from the content-addressed store, hash-verified

89
90/* Eucladian GCD */
91export function getGCD(inp_arr) {
92 let gcd_for_two = (a, b) => {
93 return a == 0?b:gcd_for_two(b % a, a);
94 };
95
96 let inp_len = inp_arr.length;
97 if(inp_len <= 2) {
98 return gcd_for_two(inp_arr[0], inp_arr[1]);
99 }
100
101 let result = inp_arr[0];
102 for(let i=1; i<inp_len; i++) {
103 result = gcd_for_two(inp_arr[i], result);
104 }
105
106 return result;
107}
108
109export function getMod(no, divisor) {
110 return ((no % divisor) + divisor) % divisor;

Callers 7

GraphsFunction · 0.90
PGDReplicationFunction · 0.90
MemoryFunction · 0.90
CpuDetailsFunction · 0.90
StorageFunction · 0.90
SummaryFunction · 0.90

Calls 1

gcd_for_twoFunction · 0.85

Tested by

no test coverage detected