title: Given value p, return last element of sequence < p - Fortran
body: <p>I have a sequence of numbers as follows:</p>
  
  <p>1 , 1, 5, 13, 41, 121, 365, ....</p>
  
  <p>The first two values are:</p>
  
  <p>N(1) = 1 and N(2) = 1</p>
  
  <p>As from 3rd value, N(i) = 2*N(i-1) + 3*N(i-2)</p>
  
  <p>The issue I am facing with is: If I give an argument of p, it should return me the last values of the sequence &lt; p (Using fortran77). </p>
  
  <p>For instance, if p = 90, it should return the value 41. </p>