(function () {
var myFunction = function () {
// выполняем здесь некие действия
};
})();
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
/* Calculate the greatest common divisor of two given numbers */ | |
#include <stdio.h> | |
int gcd(int a, int b) { | |
int r; | |
while (b > 0) { | |
r = 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
#include <stdio.h> | |
int fibonacci(int n) { | |
int a = 1, b = 1, next; | |
for (int i = 0; i < n; i++) { | |
if(i <= 1) { | |
next = 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
#include <stdio.h> | |
int factorial(int n){ | |
int a = 1; | |
for (int i = 1; i <= n; ++i) { | |
a *= i; | |
} | |
return a; |
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
private static long fibonacci(int n) { | |
long c = 1; | |
long b = 0; | |
long a = 0; | |
for (int i = 1; i <= n; i++) { | |
a = c + b; | |
c = b; | |
b = a; | |
} |
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
public int fibonacci(int n) { | |
if (n == 0) return 0; | |
if (n == 1) return 1; | |
return fibonacci(n-1) + fibonacci(n-2); | |
} |
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
import Data.List | |
import Data.Ord | |
partitions :: [a] -> [([a], [a])] | |
partitions [] = [([], [])] | |
partitions (x : xs) = let ps = partitions xs in | |
[(x : ys, zs) | (ys, zs) <- ps] ++ [(ys, x : zs) | (ys, zs) <- ps] | |
unbalance :: Num a => ([a], [a]) -> a | |
unbalance (ys, zs) = abs (sum ys - sum zs) |
struct Person {
firstname: String,
lastname: String,
age: u8,
}
impl Person {
fn full_name(&self) -> String {
format!("{} {}", self.firstname, self.lastname)
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
const http = require('http'); | |
const link = 'http://387338.xyz:8000/status-json.xsl' | |
http.get(link, (resp) => { | |
let data = ''; | |
// A chunk of data has been recieved. | |
resp.on('data', (chunk) => { | |
data += chunk; | |
}); |
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
for (var i=0; i < 101; i++){ | |
if (i % 15 == 0) console.log("FizzBuzz"); | |
else if (i % 3 == 0) console.log("Buzz"); | |
else if if (i % 5 == 0) console.log("Fizz"); | |
else console.log(i); | |
} |
OlderNewer