Sum of Perrin Numbers | function for sum of first n Perrin number . ; if ( n == 0 ) n = 0 ; if ( n == 1 ) n = 1 ; if ( n == 2 ) n = 2 ; calculate k = 5 sum of three previous step . ; Sum remaining numbers ; calculate next term ; Driver code
function calSum ( n ) { let a = 3 , b = 0 , c = 2 ; return 3 ; return 3 ; return 5 ; let sum = 5 ; while ( n > 2 ) { let d = a + b ; sum += d ; a = b ; b = c ; c = d ; n -- ; } return sum ; } let n = 9 ; document . write ( calSum ( n ) ) ;