4.6
,
4.6.4.4.
, , , , .
( ) : (. .3-10 . .3-11).
, , , , L True. . , , . ( ) .
, ( ) , , L, .
, () L , 4. 4.
- (, ), , . , , , . , .
, n - (, , n-1). :
Sn= Sn-1 + Un, Sn n , , Sn-1 Un, .
|
|
, , :
+ + +...
= 1 − + − +...
, .. .
, VB , :
Do While L [ Exit Do ]Loop | Do Until L [ Exit Do ]Loop |
, :
Do [ Exit Do ]Loop While L | Do [ Exit Do ]Loop Until L |
, DoLoop , ( Do), ( Loop).
Exit Do.
4.6.1-1. -Function, 1 n ( n!=1*2*3*4*n).
( 4.5.2-5). .
Function Pr611(ByVal n As Integer) As Long Dim I As Integer, p As Long p = 1: I = 0 Do While I < n I = I + 1: p = p * I Loop Return p End Function |
. 4.6.1-1. Pr611(),
n 6.1-1
- Futncion Pr611(), , . 4.6.1-1.
DoLoop , I n. (I<n), Do While, . (.. True), . I<n , , False. , , Loop.
, , , , , , DoLoop, , Loop While Loop Until.
- Function, , 4.6.1-2.
4.6.1-2. -Function, n, [1; 15], (.. n>=1 AND n<=15).
DoLoop Until. , False. True, .. , .
|
|
- Function Pr612() . 4.6.1-2.
Function Pr612() As Integer Dim n As Integer Do n = vvodInt9(" n (1<n<15)", TextBox1) Loop Until n >=1 And n <= 15 Return n End Function |
. 4.6.1-2. Pr612(),
4.6.1-2