There are three file descriptors open by default:
0 for stdin
1 for stdout
2 for stderr
# Eulers Totient Function | |
# | |
# Description at http://mathworld.wolfram.com/TotientFunction.html | |
# Algorithm based on http://en.wikipedia.org/wiki/Euler%27s_totient_function | |
# Interesting property: for a prime number p, epf(p) = p - 1 | |
# greatest common divisor of two integers | |
# @param m int the first number | |
# @param n int the second number | |
# @return int the greates common divisor of the two numbers |
/* Primality Test | |
* Checks if a given number is prime | |
* As inspired by http://www.khanacademy.org/cs/level-1-primality-test/1018672065 | |
*/ | |
function leastfactor(n) { | |
var m, i; | |
if (n == 0) return 0; | |
if (n % 1 || n*n < 2) return 1; | |
if (n %2 == 0) return 2; |
#include <cstring> | |
#include <cmath> | |
bool bsearch(const char* array, char ch) | |
{ | |
int a = 0; // start of the search array | |
int b = strlen(array); // end of the search array | |
int m = 0; // the middle value | |
int prev; // remembers the previous middle value | |
while(true) { |
[object HTMLElement] | |
[object HTMLElement] | |
[object HTMLElement] | |
[object HTMLAppletElement] | |
[object HTMLAreaElement] | |
[object HTMLElement] | |
[object HTMLBaseElement] | |
[object HTMLBaseFontElement] | |
[object HTMLElement] | |
[object HTMLElement] |
/** | |
* As the simple HTML document is loading, the script measures the time it | |
* takes to reach the given 'readyStates' of the DOM and of the whole | |
* document. | |
* | |
* document.readyState documentation: | |
* - http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#current-document-readiness | |
* - https://developer.mozilla.org/en-US/docs/Web/API/document.readyState | |
* | |
* window events documentation: |
data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw== |
#include <stdio.h> | |
const short FLAG_1 = 1; | |
const short FLAG_2 = 1 << 1; | |
const short FLAG_3 = 1 << 2; | |
const short FLAG_4 = 1 << 3; | |
//int settings = FLAG_1|FLAG_3|FLAG_4; | |
int settings = 0; |
// From the TRE package | |
#ifdef TRE_DEBUG | |
#include <stdio.h> | |
#define DPRINT(msg) do {printf msg; fflush(stdout);} while(/*CONSTCOND*/(void)0,0) | |
#else /* !TRE_DEBUG */ | |
#define DPRINT(msg) do { } while(/*CONSTCOND*/(void)0,0) | |
#endif /* !TRE_DEBUG */ | |
// Updated for my use |
#{ | |
f = x^2 + yx^3 + 2y | |
tangent plane at (-1, 2, f(x, y)) is: | |
4x - 6y - z + 19 | |
#} | |
tx = ty = linspace(-5, 5, 100); | |
[xx, yy] = meshgrid(tx, ty); |