Skip to content

Instantly share code, notes, and snippets.

@Cxarli
Last active August 29, 2015 14:20
Show Gist options
  • Save Cxarli/d7c6bd63de9821a16461 to your computer and use it in GitHub Desktop.
Save Cxarli/d7c6bd63de9821a16461 to your computer and use it in GitHub Desktop.
public class Math {
int[] stack=new int[1024];
{
stack[0]=1;
stack[1]=1;
}
int pointer=2;
public Math(String[] args) {
main();
}
public void main() {
int toMake=2;
while(toMake<100) {
if(!canMake(toMake))
stack[pointer++]=toMake-1;
toMake++;
print();
}
System.out.println("~~~");
System.out.println("Length: "+pointer);
}
public void print() {
System.out.println("~~~");
for(int i=0; i<pointer; i++) {
System.out.print(stack[i]+" ");
if(i%20==0 && i!=0)
System.out.print("\n");
}
System.out.print("\n");
}
public boolean canMake(int toMake) {
for(int x=0; x<pointer; x++) {
for(int y=0; y<pointer; y++) {
if(x==y) continue;
if(stack[x]+stack[y]==toMake)
return true;
}
}
return false;
}
public static Math math;
public static void main(String[] args) {
math = new Math(args);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment