summaryrefslogtreecommitdiff
path: root/3689/CH12/EX12.9/12_9.sce
blob: 4678e367cedf65d680a0c933e30baf03befa8da1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
//////Variable Declaration
N = [10,50,100]       //Valures for N

//Calculations
printf("\n   N        ln(N!)       ln(N!)sterling      Error')
for i =10

 lnN = log(factorial(i))
    lnNs = i*log(i)-i
    err = abs(lnN-lnNs)
    printf('\n%3d       %5.2f        %5.2f              %4.2f',i,lnN,lnNs, err)
end
for i =50

 lnN = log(factorial(i))
    lnNs = i*log(i)-i
    err = abs(lnN-lnNs)
    printf('\n%3d       %5.2f        %5.2f              %4.2f',i,lnN,lnNs, err)
end
for i =100

 lnN = log(factorial(i))
    lnNs = i*log(i)-i
    err = abs(lnN-lnNs)
    printf('\n%3d       %5.2f        %5.2f              %4.2f',i,lnN,lnNs, err)
end