K
K
Kirill Michenus2017-02-06 22:32:25
CoffeeScript
Kirill Michenus, 2017-02-06 22:32:25

Where is the error in the code, in the same functions?

There is code here
codepen.io/michenusweb/pen/rjrWpp
There are two identical functions here: Why does one work and the other doesn't?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tom Nolane, 2017-02-06
@michenusweb

productFib = (prod) ->
  [a, b] = [0, 1]
  [a, b] = [b, a+b] while a*b < prod
  [a, b, a*b==prod]
  
console.log productFib 4895

productFid = (plod) ->
  [c, d] = [0, 1]
  [c, d] = [d, c+d] while c*d < plod
  [c, d, c*d==plod]
  
console.log productFid 4895

ps I don't understand coffe either)
P.S.S. this code does not generate errors

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question