{"ScriptPreparationCode":"function greatestCommonDivisor(a, b){\r\n var divisor = 2, \r\n greatestDivisor = 1;\r\n\r\n //if u pass a -ve number this will not work. fix it dude!!\r\n if (a \u003C 2 || b \u003C 2)\r\n return 1;\r\n \r\n while(a \u003E= divisor \u0026\u0026 b \u003E= divisor){\r\n if(a %divisor == 0 \u0026\u0026 b% divisor ==0){\r\n greatestDivisor = divisor; \r\n }\r\n divisor\u002B\u002B;\r\n }\r\n return greatestDivisor;\r\n}\r\n\r\nfunction gcd(a,b){\r\n var divisor = a;\r\n \r\n \tif(b \u003E a)\r\n divisor = b;\r\n \r\n if(a \u003C 2 || b \u003C 2){\r\n return 1;\r\n }\r\n \r\n while(divisor \u003E 0){\r\n if(a % divisor === 0 \u0026\u0026 b % divisor === 0){\r\n return divisor;\r\n }\r\n divisor--;\r\n }\r\n}\r\n","TestCases":[{"Name":"Bottom Up","Code":"greatestCommonDivisor(1012, 10580);","IsDeferred":false},{"Name":"Top Down","Code":"gcd(1012, 10580);","IsDeferred":false}]}