

Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
rec1 dproc n T integer if n = 1 then printf %d , n ; else printf %d , n ; rec1 nK1 ; printf %d , n ; end if; end proc; rec1 := proc n::integer.
Typology: Schemes and Mind Maps
1 / 3
This page cannot be seen from the preview
Don't miss anything!


#============================================
recnumdig d proc n T posint if n! 10 then return 1; else return 1 C recnumdig trunc n 10
end if ; end proc ; recnumdig := proc n::posint if n! 10 then return 1 else return 1 Crecnumdig trunc 1 / 10 * n end if
end proc
recnumdig 10000 ; 5 #=========================================
#=========================================
rec1 d proc n T integer if n = 1 then printf " %d ", n ; else printf " %d ", n ; rec1 n K1 ; printf " %d ", n ; end if ; end proc ; rec1 := proc n::integer if n = 1 then printf " %d ", n else printf " %d ", n ; rec1 n K 1 ; printf " %d ", n end if end proc
rec1 10 ; 10 9 8 7 6 5 4 3 2 1 2 3 4 5 6 7 8 9 10
#=============recursive max ==========================
mymax d a, b /piecewise a O b , a, a % b, b ; mymax := a, b /piecewise b! a, a, a % b, b L d 1, 34, 45, 12, 34, 6, 234, 6, 78, 234, 2 ; L := 1, 34, 45, 12, 34, 6, 234, 6, 78, 234, 2 recmax d proc k T integer #return the max of L[1..k] if k = 1 then return L 1 ; else return mymax L k , recmax k K 1 ; end if ; end proc ; recmax := proc k::integer
if k = 1 then return L 1 else return mymax L k , recmax k K 1 end if
end proc
recmax nops L ; 234
rec2 d proc x T numeric, n T posint if n = 1 then return x; else return sqrt 1 Cevalf rec2 x, n K 1 ; end if ; end proc ; rec2 := proc x::numeric, n::posint if n = 1 then return x else return sqrt 1 Cevalf rec2 x, n K 1 end if
end proc
rec2 3, 4 ;
L d seq rec2 3, i , i = 1 ..30 ; L := 3, 2.000000000, 1.732050808, 1.652891650, 1.628769981, 1.621348199, 1.619057812, 1.618350337, 1.618131743, 1.618064196, 1.618043323, 1.618036873, 1.618034880, 1.618034264, 1.618034074, 1.618034015, 1.618033997, 1.618033991, 1.618033989, 1.618033989, 1.618033989, 1.618033989, 1.618033989, 1.618033989, 1.618033989, 1.618033989, 1.618033989, 1.618033989, 1.618033989, 1.
#================some symbolic math=============
recfunc d proc n T posint if n = 1 then return^1 1 Kx
else return simplify 1 1 Krecfunc n K 1
end if ; end proc ; recfunc := proc n::posint if n = 1 then return 1 / 1 K x else return simplify 1 / 1 K recfunc n K 1 end if
end proc
recfunc 10 ;
K 1 Cx L d seq recfunc i , i = 1 ..10 ; L := 1 1 Kx
, K^1 Cx x
, x, K 1 K 1 Cx
, K^1 Cx x
, x, K 1 K 1 Cx
, K^1 Cx x
, x, K 1 K 1 Cx