This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function* getResponse() { | |
yield new Promise(resolve => { | |
request('example.com', res => { | |
resolve(); | |
}); | |
}); | |
// you can have more functions. It's just a example. just do it | |
// yield new Promise .... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int checkNumbers(int n) { | |
if (n % 3 == 0 || n % 5 == 0) { | |
return 1; | |
} | |
return 0; | |
} | |
int main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int is_even(int n) { | |
if (n % 2 == 0) { | |
return 1; | |
} | |
return 0; | |
} | |
int main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let primes = []; | |
let inProgress = 600851475143; | |
let primeFactors = []; | |
function isPrime(n) { | |
for (let i = 2; i < n; i++) { | |
if (n % i === 0) { | |
return false; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let arr = []; | |
for (let i = 100; i < 1000; i++) { | |
for (let j = 100; j < 1000; j++) { | |
let answer = i * j; | |
let aStr = answer.toString().split(''); | |
if (aStr[0] === aStr[aStr.length - 1]) { | |
if (aStr[1] === aStr[aStr.length - 2]) { | |
if (aStr[2] === aStr[aStr.length - 3]) { | |
arr.push(answer); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// This is slow | |
for (let i = 1;; i++) { | |
let count = 0; | |
for (let j = 1; j < 20; j++) { | |
if (i % j === 0) { | |
count += 1; | |
} | |
} | |
if (count === 19) { | |
console.log(i); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let arrSq = []; | |
let arrSum = []; | |
for (let i = 1; i <= 100; i++) { | |
arrSq.push(i * i); | |
} | |
for (let i = 0; i <= 100; i++) { | |
arrSum.push(i); | |
} | |
arrSum = arrSum.reduce((a, b) => a + b); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
i = 3 | |
n = s = 1 | |
while (i <= 10001): | |
if (s == 1): | |
x = 6 * n -1 | |
s = 0 | |
else: | |
x = 6 * n +1 | |
s = 1 | |
n = n + 1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
strings = [ | |
"73167176531330624919225119674426574742355349194934", | |
"96983520312774506326239578318016984801869478851843", | |
"85861560789112949495459501737958331952853208805511", | |
"12540698747158523863050715693290963295227443043557", | |
"66896648950445244523161731856403098711121722383113", | |
"62229893423380308135336276614282806444486645238749", | |
"30358907296290491560440772390713810515859307960866", | |
"70172427121883998797908792274921901699720888093776", | |
"65727333001053367881220235421809751254540594752243", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdio.h> | |
int pythagorean(int num) { | |
for (int i = 1; i < num; i++) { | |
for (int j = 1; j < num - 1; j++) { | |
const int k = num - i - j; | |
if ((i * i) + (j * j) == (k * k)) { | |
return i * j * k; | |
} | |
} |
OlderNewer