،
متسلسلة لانهائية
لحساب مجموع برنامج
print "I will compute the partial sum of the given series"
print "I will ignore terms which less than a toleronce of" print "your choice"
input "kindly give me your tolorence", epsilon
sum.of.terms
no.of.terms
1 1
input "give me the value of x at which the series is be computed",x
term = -x
while abs(term) > epsilon
sum.of.terms
=
sum.of.terms+term
no.of.terms = no.of.terms + 1
term = -x * term / no.of.terms
wend
print "at x="; x;" the"; no.of.terms;" th partial sum is"; sum.of.terms
end
ملاحظة هامة: حذار من المتسلسلات المتباعدة حيث أنه موضوع رياضي ليس يسيرا، ولا يسمح لنا مثل هذا المقرر الدخول في تفاصيله ولكن كن حذرا وغير أمر إيقاف الحلقة ليحوي :
WHILE ABS(TERM) > EPSILON OR N > 1000
٢٠٤
أي أن شرط الإيقاف أصبح الآن يتحقق عندما يكون الحد الذي سيضاف صغيرا أو عندما يزيد عن ألف حد ، وبهذا فإن التكرار سيتوقف حتى لو
كانت المتسلسلة تباعدية .
ج٢ ص٢٠٤