Last active
          November 4, 2021 18:34 
        
      - 
      
 - 
        
Save paulodutra/d6e6bf660b6fa3407deaeba98844354a to your computer and use it in GitHub Desktop.  
    Calculate fibonnaci 
  
        
  
    
      This file contains hidden or 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
    
  
  
    
  | function fibonacci(number){ | |
| let term = number; | |
| let penultimate = 0, last = 1; | |
| let result = 0; | |
| if (term <= 2) { | |
| result = term - 1; | |
| } else { | |
| for( let i = 3; i<= term; i++){ | |
| result = last + penultimate; | |
| penultimate = last; | |
| last = result; | |
| } | |
| } | |
| return result; | |
| } | |
| console.log(fibonacci(8)); | |
| console.log(fibonacci(13)); | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment