列表

详情


FED27. 余数

描述

请补全JavaScript函数,要求返回数字参数除以2的余数。

原站题解

HTML/CSS/JavaScript 解法, 执行用时: 1682ms, 内存消耗: 77820KB, 提交时间: 2022-02-09

{"css":"","js":"function _remainder(value) {\n    // 补全代码\n    return value % 2    //对2取余数\n}","html":"","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1686ms, 内存消耗: 77792KB, 提交时间: 2022-02-09

{"css":"","js":"function _remainder(value) {\n    // 补全代码\n                var a=value;\n            while (a>=2) {\n                a=a/2;\n            }\n            return a;\n}","html":"","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1734ms, 内存消耗: 77772KB, 提交时间: 2021-12-10

{"css":"","js":"function _remainder(value) {\n    return value % 2;\n}\nfunction _remainder(value) {\n    return value - (value >> 2);\n}\n","html":"","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1741ms, 内存消耗: 77820KB, 提交时间: 2021-12-17

{"css":"","js":"function _remainder(value) {\n    // 补全代码\n    if(value%2===0){\n        return 0;\n    } else {\n        return value%2;\n    }\n}","html":"","libs":[]}

HTML/CSS/JavaScript 解法, 执行用时: 1741ms, 内存消耗: 77872KB, 提交时间: 2021-12-16

{"css":"","js":"function _remainder(value) {\n    // 补全代码\nreturn    value%2\n}","html":"","libs":[]}

上一题