Skip to content

Instantly share code, notes, and snippets.

@soswow
Created August 2, 2015 03:35
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 soswow/7c0793a79f18bdf3fe41 to your computer and use it in GitHub Desktop.
Save soswow/7c0793a79f18bdf3fe41 to your computer and use it in GitHub Desktop.
f = (n) ->
if n is 0
0
else if n is 1
1
else
f(n-1) + f(n-2)
process.on 'message', (input) ->
output = f(input)
process.send output
module.exports = f
fork = require('child_process').fork
fibCp = fork(__dirname + '/fib')
fibCp.on 'message', (result) ->
console.log result
$ ->
$('#fib-start').click ->
fibCp.send 45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment