Skip to content

Instantly share code, notes, and snippets.

@dbarjs
Last active April 4, 2022 17:22
Show Gist options
  • Save dbarjs/4c89bc87701a4280340d to your computer and use it in GitHub Desktop.
Save dbarjs/4c89bc87701a4280340d to your computer and use it in GitHub Desktop.
Foi algum desafio de código escrito em 2015
this._ = this._ || {};
(function (_) {
_.a = function(a, b) {
if (a > b) return _.a((a - 1) / 2, b);
return a;
};
_.b = function(a, b) {
var c = _.a(a, b);
if (c % 1 === 0) return c;
return false;
};
_.c = function(a, b) {
var c = _.b(a, b);
if (c == b) return c;
return false;
};
_.d = function (a, b) {
var c = new Array();
for (var d = a; b > c.length ; d++) {
var e = _.c(d, a);
if (e) c.push(d);
}
return c;
};
_.e = function (a, b) {
var c = _.d(a, b),
d = c[c.length - 1].toString(),
e = new Array();
for (var f = 0, g = d.length; f < g; f++) e.push(parseInt(d.substr(f, f + 1)));
return e;
};
_.f = function (a) {
var b = 0;
for (var c = 0, d = a.length; c < d; c++) b += a[c];
return b;
};
})(this._);
console.log(_.f(_.e(2, 4))); // 5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment