Created
March 28, 2012 05:50
-
-
Save gwing33/2224039 to your computer and use it in GitHub Desktop.
Wanted to find out the degrees within the fibonacci sequence...
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
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