RSI = 100 * UpAvg / (UpAvg + DnAvg)
Where UpAvg is the average positive change over the period and where DnAvg is the average negative change over the period.
So if you have RSI(5), and your closes are:
10,11,13,12,11.50
UpAvg = ([-10+11] + [-11+13])/5
DnAvg = ([13-12] +...