Program for Perrin numbers | Optimized Javascript program for n 'th perrin number ; Driver code
function per ( n ) { let a = 3 ; let b = 0 ; let c = 2 ; let i ; let m ; if ( n == 0 ) return a ; if ( n == 1 ) return b ; if ( n == 2 ) return c ; while ( n > 2 ) { m = a + b ; a = b ; b = c ; c = m ; n -- ; } return m ; } n = 9 ; document . write ( per ( n ) ) ;