Skip to content

Instantly share code, notes, and snippets.

@gwing33
Created March 28, 2012 05:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gwing33/2224039 to your computer and use it in GitHub Desktop.
Save gwing33/2224039 to your computer and use it in GitHub Desktop.
Wanted to find out the degrees within the fibonacci sequence...
var fibonacci_sequence = [0,1],
degrees = [],
dup_degrees = [];
var fibonacci_total = 0,
prev_num = 0,
cur_num = 1;
var degree,
has_degree;
// Build the Fibonacci Sequence
for(i = 0; i <= 100; i++) {
fibonacci_sequence[fibonacci_sequence.length] = prev_num + cur_num;
prev_num = cur_num;
cur_num = fibonacci_sequence[fibonacci_sequence.length-1];
}
// Total up the Fibonacci Sequence and mod by 360, remove dups
for(i = 0; i < fibonacci_sequence.length; i++) {
fibonacci_total += fibonacci_sequence[i];
degree = fibonacci_total % 360;
has_degree = false;
for(j = 0; j < degrees.length; j++) {
if(degree == degrees[j]) {
has_degree = true;
}
}
if(!has_degree) {
degrees[degrees.length] = degree;
} else {
dup_degrees[dup_degrees.length] = degree;
}
}
console.log( fibonacci_sequence );
console.log( degrees );
console.log( degrees.length );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment