Stirling’s Formula

Stirling’s Formula :

ALGORITHM :

  1. Start of the program.
  2. Input number of terms n
  3. Input the array ax
  4. Input the array ay
  5. h = ax[1]-ax[0]
  6. for i = 1;i < n-1; i++
  7. diff [i][1] = ay[i + 1]-ay[i]
  8. end loop i
  9. for j = 2; j < = 4; j++
  10. for i = 0; i < n-j; i++
  11. diff[i][j] = diff[i + 1][j-1]-diff[i][j-1]
  12. End loop i
  13. End loop j
  14. i = 0
  15. Repeat step 16 until ax[i] < x
  16. i = i + 1
  17. i = i-1;
  18. p = (x-ax[i])/h
  19. y1= p*(diff[i][1] + diff[i-1][1])/2
  20. y2 = p*p*diff[i-1][2]/2
  21. y3 = p*(p*p-1)*(diff[i-1][3]+diff[i-2][3])/6
  22. y4 = p*p*(p*p-1)*diff[i-2][4]/24
  23. y = ay[i]+y1 + y2 + y3 + y4
  24. Print output
  25. End of program
C SOURCE CODE :

OUTPUT : 

stirling's formula


Leave a Reply

Your email address will not be published. Required fields are marked *