Hofstadter Figure-Figure sequences: Difference between revisions
Content added Content deleted
(CoffeeScript version) |
(CoffeeScript: bug fixed) |
||
Line 510: | Line 510: | ||
[1..10].map (i) -> console.log 'R(' + i + ') = ' + ffr(i) |
[1..10].map (i) -> console.log 'R(' + i + ') = ' + ffr(i) |
||
int_array = [1..40].map ffr |
int_array = ([1..40].map ffr).concat [1..960].map ffs |
||
int_array.concat [1..960].map ffs |
|||
int_array.sort (a, b) -> a - b |
int_array.sort (a, b) -> a - b |
||
i = 1 |
|||
check = (i) -> |
|||
while i <= 1000 |
|||
if int_array[i - 1] != i |
if int_array[i - 1] != i |
||
throw 'Something\'s wrong!' |
throw 'Something\'s wrong!' |
||
else |
|||
check i for i in [1..1000] |
|||
console.log '1000 integer check ok.' |
|||
console.log '1000 integer check ok.'</lang> |
|||
{{out}} |
{{out}} |
||
As JavaScript. |
As JavaScript. |