Tonto | ||
---|---|---|
<< Previous | Next >> |
The INT module is concerned with integers. This illustrates basic functionality including a routine to return the Legendre polynomial coefficients.
program run_int use TYPES use SYSTEM use STR use INT use REAL use TEXTFILE #include "macros" implicit none INT :: i REALVEC* :: answer tonto.initialize stdout.create_stdout stdout.open stdout.flush stdout.text("Factorials:") stdout.flush do i = 0,15 stdout.text( i.to_str.trim //"! = " & // i.factorial.to_str_no_zeros.trim ) end stdout.flush stdout.text("Double factorials:") stdout.flush do i = 0,15 stdout.text( i.to_str.trim //"!! = " & // i.double_factorial.to_str_no_zeros.trim ) end stdout.set_real_precision(2) stdout.set_real_width(7) stdout.set_fields(10) stdout.flush stdout.text("Coefficients of the Legendre polynomials:") stdout.flush do i = 0,8 allocate(answer(i+1)) answer = i.legendre_polynomials stdout.show("n = "//i.to_str.trim//", coeffs = ",answer) deallocate(answer) end end |
Factorials: 0! = 1 1! = 1 2! = 2 3! = 6 4! = 24 5! = 120 6! = 720 7! = 5040 8! = 40320 9! = 362880 10! = 3628800 11! = 39916800 12! = 479001600 13! = 6227020800 14! = 87178291200 15! = 1307674368000 Double factorials: 0!! = 1 1!! = 1 2!! = 3 3!! = 15 4!! = 105 5!! = 945 6!! = 10395 7!! = 135135 8!! = 2027025 9!! = 34459425 10!! = 654729075 11!! = 13749310575 12!! = 316234143225 13!! = 7905853580625 14!! = 213458046676875 15!! = 6190283353629375 Coefficients of the Legendre polynomials: n = 0, coeffs = 1.00 n = 1, coeffs = 0.00 1.00 n = 2, coeffs = -0.50 0.00 1.50 n = 3, coeffs = 0.00 -1.50 0.00 2.50 n = 4, coeffs = 0.38 0.00 -3.75 0.00 4.38 n = 5, coeffs = 0.00 1.88 0.00 -8.75 0.00 7.88 n = 6, coeffs = -0.31 0.00 6.56 0.00 -19.69 0.00 14.44 n = 7, coeffs = 0.00 -2.19 0.00 19.69 0.00 -43.31 0.00 26.81 n = 8, coeffs = 0.27 0.00 -9.84 0.00 54.14 0.00 -93.84 0.00 50.27 |