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 <vector> | |
#include <iostream> | |
#include <algorithm> | |
class Primegen | |
{ | |
std::vector<int> primes; //store all the primes we've generated so far | |
void nextprime(void); //add one new prime to the end of the list | |
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
class Pentagonals(object): | |
def __init__(self): | |
self._nums={} | |
def add_pent(self): | |
n=len(self._nums)+1 | |
self._nums[n-1]=(n*((3*n)-1)/2) | |
def is_pent(self, n): | |
return n in self._nums |
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
int VM::run(std::string state) | |
{ | |
r1=r2=r3=r4=r5=0; | |
for(int i=0; i<256;i++) | |
{ | |
memory[i]=0; | |
} | |
load(state); | |
mainloop(); |
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 <iostream> | |
#include <fstream> | |
#include <cstdlib> | |
#include <cstring> | |
class State | |
{ | |
unsigned char s[256]; | |
int i, j; |
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 <string> | |
#include <iostream> | |
#include <sstream> | |
#include <algorithm> | |
class Hugenum | |
{ | |
public: | |
std::string str; //stores the number in decimal form, this is a horrible way to store numbers, but it works for almost any size we can imagine |
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 <iostream> | |
#include <fstream> | |
#include <cstdlib> | |
#include <cstdio> | |
#include <cstring> | |
class State | |
{ | |
unsigned char s[256]; | |
int i, j; |
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> | |
double bang(int i) | |
{ | |
return i==0?1:(double) i * bang(i-1); | |
} | |
double ncr(int n, int r) | |
{ | |
double numerator=bang(n); |
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> | |
#include <stdbool.h> | |
#include <string.h> | |
#include <math.h> | |
void digits ( char digits[10], int n ) | |
{ | |
int top=(int)log10((float)n)+1; | |
int i=0; |
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> | |
#include <stdlib.h> | |
#include <stdbool.h> | |
bool palindrome ( unsigned long long int i ); | |
unsigned long long int reverse ( unsigned long long int i ); | |
bool lychrel ( unsigned long long int i ); | |
int main ( void ) | |
{ |
NewerOlder