Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.