Skip to content

Instantly share code, notes, and snippets.

$> gcc -o fib -O3 fib.c
$> time ./fib_num
165580141
real 0m1.452s
user 0m1.448s
sys 0m0.000s
$> javac FibNum.java
$> time java -server FibNum
abstract class Shape {
}
class Rectangle extends Shape {
}
class Square extends Shape {
}
class Person
{
private String name;
public Person(String name) {
this.name = name;
}
public Person() {
}
int missing(int a[], int n) {
double num = n + 1;
double ideal_sum = (num * (num + 1)) / 2;
int sum = 0;
int i;
for (i = 0; i < n; i++) {
sum += a[i];
}
int get_max_range(int a[], int n, int *start, int *end)
{
int temp_sum = 0, sum = 0, found = -1;
int i, j;
for (i = 0; i < n - 1; i++) {
temp_sum = a[i];
*start = i;
for (j = i;j < n; j++) {
temp_sum = a[j];
'''Read an html file from a file like object, parse(possibly selective) it and give back the data to the callback for processing.
'''
import urllib2
import re
import sys
from BeautifulSoup import BeautifulSoup
from BeautifulSoup import SoupStrainer
# Inline configs.
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
int equi(int a[], int n ) {
int i, j;
long int sum = 0;
int **sum_list = calloc(sizeof *sum_list, n);
assert(sum_list != NULL);
for (i = 0; i < n; i++) {
#include <stdio.h>
double fib(int num)
{
if (num <= 1)
return 1;
else
return fib(num-1) + fib(num-2);
}
public class FibNum {
public static void main(String args[]) {
System.out.printf("%.0f\n", fib(Integer.parseInt(args[0])));
}
public static double fib(int n) {
if (n <= 1)
return 1;
else
return fib(n-1) + fib(n-2);
}
$> gcc -o fib fib_num.c
$> time ./fib
165580141
real 0m3.606s
user 0m3.604s
sys 0m0.000s