You are on page 1of 33

bi 1:tnh tng S=1+2+3+...

+n
Module Module1 Function Tong(ByVal n As Integer) As Integer Dim S As Integer = 0 Dim i As Integer For i = 0 To n Step 1 S = S i !e"t #eturn S $nd Function Su% Main() Dim n As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() Dim -. As Integer = 10 -. = Tong(n) &onsole'(rite)ine(*/et .ua , * 0 -.) $nd Su% $nd Module

S=1^2+2^2+3^2+.....n^n
Function Tong(ByVal n As Integer) As Integer Dim S As Integer = 0 Dim i As Integer For i = 0 To n Step 1 S = S i 1 i !e"t #eturn S $nd Function Su% Main() Dim n As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() Dim -. As Integer -. = Tong(n) &onsole'(rite)ine(*/et .ua , * 0 -.) $nd Su% $nd Module

S= 1+1/2+1/3+...+1/n
Module Module1 Function Tong(ByVal n As Integer) As Dou%le Dim S As Dou%le = 0 Dim i As Integer For i = 1 To n Step 1 S = S (1 2 i) !e"t #eturn S $nd Function Su% Main() Dim n As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() Dim -. As Dou%le -. = Tong(n) &onsole'(rite)ine(*/et .ua , * 0 -.)

$nd Su% $nd Module

S= 1/2 + 1/4 +...+1/2n


Module Module1 Function Tong(ByVal n As Integer) As Dou%le Dim S As Dou%le = 0 Dim i As Integer For i = 1 To n Step 1 S = S 1 2 (3 1 i) !e"t #eturn S $nd Function Su% Main() Dim n As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() Dim -. As Dou%le -. = Tong(n) &onsole'(rite)ine(*/et .ua , * 0 -.) $nd Su% $nd Module

S= 1+ 1/3 + 1/5+..+1/2n+1
Module Module1 Function Tong(ByVal n As Integer) As Dou%le Dim S As Dou%le = 1 Dim i As Integer For i = 1 To n Step 1 S = S 1 2 (3 1 i 1) !e"t #eturn S $nd Function Su% Main() Dim n As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() Dim -. As Dou%le -. = Tong(n) &onsole'(rite)ine(*/et .ua , * 0 -.) $nd Su% $nd Module

SS=1/1*2 + 1/2*3 +... +1/n*(n+1)


Module Module1 Function Tong(ByVal n As Integer) As Dou%le Dim S As Dou%le = 0 Dim i As Integer For i = 1 To n Step 1 S = S 1 2 (i 1 (i 1)) !e"t #eturn S $nd Function

Su% Main() Dim n As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() Dim -. As Dou%le -. = Tong(n) &onsole'(rite)ine(*/et .ua , * 0 -.) $nd Su% $nd Module

S=1/2 +2/3+..+n/n+1
Module Module1 Function Tong(ByVal n As Integer) As Dou%le Dim S As Dou%le = 0 Dim i As Integer For i = 1 To n Step 1 S = S i 2 (i 1) !e"t #eturn S $nd Function Su% Main() Dim n As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() Dim -. As Dou%le -. = Tong(n) &onsole'(rite)ine(*/et .ua , * 0 -.) $nd Su% $nd Module

S=1/2 +3/4+..+2n+1/2n+1
Module Module1 Function Tong(ByVal n As Integer) As Dou%le Dim S As Dou%le = 0 Dim i As Integer For i = 0 To n Step 1 S = S (3 1 i 1) 2 (3 1 i 3) !e"t #eturn S $nd Function Su% Main() Dim n As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() Dim -. As Dou%le -. = Tong(n) &onsole'(rite)ine(*/et .ua , * 0 -.) $nd Su% $nd Module

T= 1*2*3*...*n

Module Module1 Function Tic+(ByVal n As Integer) As Integer Dim T As Integer = 1 Dim i As Integer For i = 1 To n Step 1 T = T 1 i

!e"t #eturn T $nd Function Su% Main() Dim n As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() Dim -. As Dou%le -. = Tic+(n) &onsole'(rite)ine(*/et .ua , * 0 -.) $nd Su%

T =x^n

Function )uyT+ua(ByVal " As Dou%le4 ByVal n As Integer) As Dou%le Dim T As Dou%le T = " 5 n #eturn T $nd Function Su% Main() Dim n4 " As Integer &onsole'(rite)ine(*!+ap Vao So ", *) " = &onsole'#ead)ine() &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() Dim -. As Dou%le -. = )uyT+ua("4 n) &onsole'(rite)ine(*/et .ua , * 0 -.) $nd Su%

$nd Module

S= 1+1*2+ 1*2*3+..+1*2*3*..*n
Module Module1 Function TongTic+(ByVal n As Integer) As Integer Dim T As Integer = 1 Dim S As Integer = 0 Dim i As Integer For i = 1 To n Step 1 T = T 1 i S = S T !e"t #eturn S $nd Function Su% Main() Dim n As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() Dim -. As Integer -. = TongTic+(n) &onsole'(rite)ine(*/et .ua , * 0 -.) $nd Su% $nd Module

S=x+x^2 + x^3 +...+x^n

Module Module1 Function TongMu(ByVal " As Dou%le4 ByVal n As Integer) As Dou%le Dim T As Integer = 1 Dim S As Integer = 0 Dim i As Integer

For i = 1 To n Step 1 T = " 5 i S = S T !e"t #eturn S $nd Function Su% Main() Dim n4 " As Integer &onsole'(rite)ine(*!+ap Vao So ", *) " = &onsole'#ead)ine() &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() Dim -. As Dou%le -. = TongMu("4 n) &onsole'(rite)ine(*/et .ua , * 0 -.) $nd Su% $nd Module

S=x^2 + x^4 +...+x^2n


Module Module1 Function TongMu(ByVal " As Dou%le4 Dim T As Integer = 1 Dim S As Integer = 0 Dim i As Integer For i = 1 To n Step 1 T = " 5 (3 1 i) S = S T !e"t #eturn S $nd Function Su% Main() Dim n4 " As Integer &onsole'(rite)ine(*!+ap Vao So " = &onsole'#ead)ine() &onsole'(rite)ine(*!+ap Vao So n = &onsole'#ead)ine() Dim -. As Dou%le -. = TongMu("4 n) &onsole'(rite)ine(*/et .ua , * $nd Su% $nd Module ByVal n As Integer) As Dou%le

", *) n, *)

0 -.)

S=x + x^3 + x^5 +...+x^2n+1


Module Module1 Function TongMu(ByVal " As Dou%le4 ByVal n As Integer) As Dou%le Dim T As Integer = 1 Dim S As Integer = 0 Dim i As Integer For i = 0 To n Step 1 T = " 5 (3 1 i 1) S = S T !e"t #eturn S $nd Function Su% Main() Dim n4 " As Integer &onsole'(rite)ine(*!+ap Vao So ", *) " = &onsole'#ead)ine() &onsole'(rite)ine(*!+ap Vao So n, *)

n = &onsole'#ead)ine() Dim -. As Dou%le -. = TongMu("4 n) &onsole'(rite)ine(*/et .ua , * 0 -.) $nd Su% $nd Module

S=1 +1 /(1+2) +1 /(1+2+3)+... +1/(1+2+3+..+n)


Module Module1 Function Tong(ByVal n As Integer) As Dou%le Dim S As Dou%le = 0 Dim M As Integer = 0 Dim i As Integer For i = 1 To n Step 1 M = M i S = S (1 2 M) !e"t #eturn S $nd Function Su% Main() Dim n As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() Dim -. As Dou%le -. = Tong(n) &onsole'(rite)ine(*/et .ua , * 0 -.) $nd Su% $nd Module

S=x +x^2 /(1+2) +x^3 / (1+2+3)+...+x^n/(1+2+3+..+n)


Module Module1 Function Tong(ByVal " As Dou%le4 ByVal n As Integer) As Dou%le Dim S As Dou%le = 0 Dim M As Integer = 0 Dim i As Integer For i = 1 To n Step 1 M = M i S = S (" 5 i) 2 M !e"t #eturn S $nd Function Su% Main() Dim " As Integer &onsole'(rite)ine(*!+ap Vao So ", *) " = &onsole'#ead)ine() Dim n As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() Dim -. As Dou%le -. = Tong("4 n) &onsole'(rite)ine(*/et .ua , * 0 -.) $nd Su% $nd Module

S=x +x^2 /2! +x^3 /3!+... +x^n/n!

Module Module1 Function Tong(ByVal " As Dou%le4 ByVal n As Integer) As Dou%le Dim S As Dou%le = 0 Dim M As Integer = 1 Dim i As Integer For i = 1 To n Step 1 M = M 1 i S = S (" 5 i) 2 M !e"t #eturn S $nd Function Su% Main() Dim " As Integer &onsole'(rite)ine(*!+ap Vao So ", *) " = &onsole'#ead)ine() Dim n As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() Dim -. As Dou%le -. = Tong("4 n) &onsole'(rite)ine(*/et .ua , * 0 -.) $nd Su% $nd Module

S=1 +x^2 /2! +x^4 /4!+... +x^2n/(2n)!

Module Module1 Function Tong(ByVal " As Dou%le4 ByVal n As Integer) As Dou%le Dim S As Dou%le = 1 Dim M As Integer = 1 Dim T As Dou%le = " Dim i As Integer For i = 3 To 3 1 n Step 3 T = " 5 i M = M 1 (i 6 1) 1 i S = S T 2 M !e"t #eturn S $nd Function Su% Main() Dim " As Integer &onsole'(rite)ine(*!+ap Vao So ", *) " = &onsole'#ead)ine() Dim n As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() Dim -. As Dou%le -. = Tong("4 n) &onsole'(rite)ine(*/et .ua , * 0 -.) $nd Su% $nd Module

S=1 +x +x^3 /3! +x^5/5!+... +x^2n+1/(2n+1)!


Module Module1 Function Tong(ByVal " As Dou%le4 ByVal n As Integer) As Dou%le Dim S As Dou%le = 1 " Dim M As Integer = 1 Dim T As Dou%le = " Dim i As Integer For i = 7 To 3 1 n 1 Step 3 T = " 5 i M = M 1 i 1 (i 6 1) S = S T 2 M !e"t #eturn S $nd Function Su% Main() Dim " As Integer &onsole'(rite)ine(*!+ap Vao So ", *) " = &onsole'#ead)ine() Dim n As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() Dim -. As Dou%le -. = Tong("4 n) &onsole'(rite)ine(*/et .ua , * 0 -.) $nd Su% $nd Module

bai 20:li t !" t#t $% $&$ '($ )* $+a )* ng,-"n .'/ng:


Module Module1 Su% 8ocSo(ByVal n As Integer) Dim i As Integer For i = 1 To n Step 1 I9 (n Mod i = 0) T+en &onsole'(rite(i 0 * *) $nd I9 !e"t $nd Su% Su% Main() Dim n As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() &onsole'(rite)ine(*Tat &a &ac 8oc So &ua :0;, *4 n) 8ocSo(n) $nd Su% $nd Module

bai 21:Tnh Tng t#t $% $&$ '($ )* $+a )* ng,-"n .'/ng:


Module Module1 Function Tong8ocSo(ByVal n As Integer) As Integer Dim S As Integer Dim i As Integer

For i = 1 To n Step 1 I9 (n Mod i = 0) T+en S = S i $nd I9 !e"t #eturn S $nd Function Su% Main() Dim n4 -. As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tong8ocSo(n) &onsole'(rite)ine(*Tong Tat &a &ac 8oc So &ua :0;, :1;*4 n4 -.) $nd Su% $nd Module

bai 22:Tnh T$h t#t $% $&$ '($ )* $+a )* ng,-"n .'/ng:


Module Module1 Function Tic+8ocSo(ByVal n As Integer) As Integer Dim T As Integer = 1 Dim i As Integer For i = 1 To n Step 1 I9 (n Mod i = 0) T+en T = T 1 i $nd I9 !e"t #eturn T $nd Function Su% Main() Dim n4 -. As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tic+8ocSo(n) &onsole'(rite)ine(*Tic+ Tat &a &ac 8oc So &ua :0;, :1;*4 n4 -.) $nd Su% $nd Module

bai 23:012 S* 3'4ng '($ )* $+a )* ng,-"n .'/ng:


Module Module1 Function Dem8ocSo(ByVal n As Integer) As Integer Dim D As Integer Dim i As Integer For i = 1 To n Step 1 I9 (n Mod i = 0) T+en D = 1 $nd I9 !e"t #eturn D $nd Function Su% Main() Dim n4 -. As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Dem8ocSo(n) &onsole'(rite)ine(* So )uong 8oc So &ua :0;, :1;*4 n4 -.)

$nd Su% $nd Module

bai 24:3i t !" t#t $% $&$ '($ )* $+a )* ng,-"n .'/ng:


Module Module1 Su% )iet/e8ocSo)e(ByVal n As Integer) Dim i As Integer &onsole'(rite)ine(*Tat &a &ac 8oc So )e &ua :0;, *4 n) For i = 1 To n Step 3 I9 (n Mod i = 0) T+en &onsole'(rite(i 0 * *) $nd I9 !e"t $nd Su% Su% Main() Dim n As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() )iet/e8ocSo)e(n) $nd Su% $nd Module

bai 25:Tnh Tng t#t $% $&$ 5'($ )* $h6n5$+a )* ng,-"n .'/ng:


Module Module1 Su% )iet/e8ocSo&+an(ByVal n As Integer) Dim i As Integer &onsole'(rite)ine(*Tat &a &ac 8oc So &+an &ua :0;, *4 n) For i = 3 To n Step 3 I9 (n Mod i = 0) T+en &onsole'(rite(i 0 * *) $nd I9 !e"t $nd Su% Su% Main() Dim n As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() )iet/e8ocSo&+an(n) $nd Su% $nd Module

bai 27:Tnh T$h t#t $% $&$ 5'($ )* l85$+a )* ng,-"n .'/ng:


Module Module1 Function Tic+8ocSo)e(ByVal n As Integer) As Integer Dim T As Integer = 1 Dim i As Integer For i = 1 To n Step 3 I9 (n Mod i = 0) T+en T = T 1 i $nd I9 !e"t #eturn T $nd Function

Su% Main() Dim n4 -. As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tic+8ocSo)e(n) &onsole'(rite)ine(*Tic+ Tat &a &ac 8oc So )e &ua :0;, :1;*4 n4 -.) $nd Su% $nd Module

bai 29:012 )* l'4ng 5'($ )* $h6n5$+a )* ng,-"n .'/ng:

Module Module1 Function Dem8ocSo(ByVal n As Integer) As Integer Dim D As Integer Dim i As Integer For i = 3 To n Step 3 I9 (n Mod i = 0) T+en D = 1 $nd I9 !e"t #eturn D $nd Function Su% Main() Dim n4 -. As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Dem8ocSo(n) &onsole'(rite)ine(* So )uong 8oc So &+an &ua :0;, :1;*4 n4 -.) $nd Su% $nd Module

bi 2::;h< )* ng,-"n .'/ng = >tnh tng $&$ )* ng,-"n .'/ng nh? h/n $hnh n@

Module Module1 Function Tong8ocSo(ByVal n As Integer) As Integer Dim S As Integer Dim i As Integer For i = 1 To n 6 1 Step 1 I9 (n Mod i = 0) T+en S = S i $nd I9 !e"t #eturn S $nd Function Su% Main() Dim n4 -. As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tong8ocSo(n) &onsole'(rite)ine(*Tong Tat &a &ac 8oc So !+o <on :0;, :1;*4 n4 -.) $nd Su% $nd Module

bi 2A:tB2 '($ )* l8 l(n nh#t $+a )* ng,- n .'/ng =


Module Module1 Function Tong8ocSo(ByVal n As Integer) As Integer Dim T As Integer Dim i As Integer For i = 1 To n 6 1 Step 3 I9 (n Mod i = 0) T+en T = i $nd I9 !e"t #eturn T $nd Function Su% Main() Dim n4 -. As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tong8ocSo(n) &onsole'(rite)ine(*8oc So )e )on !+at &ua :0;, :1;*4 n4 -.) $nd Su% $nd Module

Ci 30: !iD2 tEa )* ng,-"n .'/ng = $@ Fh% )* G<n thi n HI


Module Module1 Function /T<oanT+ien(ByVal n As Integer) As Integer Dim S As Integer Dim i As Integer For i = 1 To n 6 1 Step 1 I9 (n Mod i = 0) T+en S = S i $nd I9 !e"t I9 S = n T+en #eturn 1 $lse #eturn 0 $nd I9 $nd Function Su% Main() Dim n4 -. As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = /T<oanT+ien(n) I9 -. = 1 T+en &onsole'(rite)ine(*:0; )a So <oan T+ien *4 n) $lse &onsole'(rite)ine(*:0; /+ong )a So <oan T+ien *4 n) $nd I9 $nd Su% $nd Module

Ci 30: !iD2 tEa )* ng,-"n .'/ng = $@ Fh% )* =g,-"n T* HI


Module Module1 Function /T!guyenTo(ByVal n As Integer) As Integer Dim D As Integer Dim i As Integer For i = 1 To n Step 1 I9 (n Mod i = 0) T+en D = D 1 $nd I9 !e"t I9 D = 3 T+en #eturn 1 $lse #eturn 0 $nd I9 $nd Function Su% Main() Dim n4 -. As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = /T!guyenTo(n) I9 -. = 1 T+en &onsole'(rite)ine(*:0; )a So !guyen to *4 n) $lse &onsole'(rite)ine(*:0; /+ong )a So !guyen To *4 n) $nd I9 $nd Su% $nd Module

Bi 32: kim tra s nguyn dng N c ph s Chnh

hng !"

Module Module1 Function /T&+in+=+uong(ByVal n As Integer) As Integer Dim D As Integer Dim i As Integer For i = 1 To n Step 1 D = i 1 i I9 D = n T+en #eturn 1 $nd I9 !e"t #eturn 0 $nd Function Su% Main() Dim n4 -. As Integer &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = /T&+in+=+uong(n) I9 -. = 1 T+en &onsole'(rite)ine(*:0; )a So &+in+ =+uong *4 n) $lse &onsole'(rite)ine(*:0; /+ong )a So &+in+ =+uong*4 n) $nd I9 $nd Su% $nd Module

bi 33: Tng ;Jn CK$ 2


Module Module1 Function Tong&an(ByVal n As Integer) As Dou%le Dim S As Dou%le = 0 Dim i As Integer For i = 1 To n Step 1 S = Mat+'S.rt(3 S) !e"t #eturn S $nd Function Su% Main() Dim n As Integer Dim -. As Dou%le &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tong&an(n) &onsole'(rite)ine(*/et >ua , :0;*4 -.) $nd Su% $nd Module

bi 34:

Module Module1 Function Tong&an(ByVal n As Integer) As Dou%le Dim S As Dou%le = 0 Dim i As Integer For i = 1 To n Step 1 S = Mat+'S.rt(i S) !e"t #eturn S $nd Function Su% Main() Dim n As Integer Dim -. As Dou%le &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tong&an(n) &onsole'(rite)ine(*/et >ua , :0;*4 -.) $nd Su% $nd Module

bi 35:

Module Module1 Function Tong&an(ByVal n As Integer) As Dou%le Dim S As Dou%le = 0 Dim i As Integer For i = n To 1 Step 61 S = Mat+'S.rt(i S) !e"t #eturn S $nd Function Su% Main() Dim n As Integer Dim -. As Dou%le &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tong&an(n) &onsole'(rite)ine(*/et >ua , :0;*4 -.) $nd Su% $nd Module

bi 37:
Module Module1 Function Tong&an(ByVal n As Integer) As Dou%le Dim S As Dou%le Dim T As Integer = 1 Dim i As Integer For i = 1 To n Step 1 T = T 1 i S = Mat+'S.rt(T S) !e"t #eturn S $nd Function Su% Main() Dim n As Integer Dim -. As Dou%le &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tong&an(n) &onsole'(rite)ine(*/et >ua , :0;*4 -.) $nd Su% $nd Module

bi 39

Module Module1 Function Tong&an(ByVal n As Integer) As Dou%le Dim S As Dou%le Dim i As Integer For i = 3 To n Step 1 S = Mat+'=o?(i S4 1 2 i) !e"t #eturn S $nd Function Su% Main() Dim n As Integer Dim -. As Dou%le &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tong&an(n) -. = Mat+'=o?(@'@14 1 2 7) &onsole'(rite)ine(*/et >ua , :0;*4 -.) $nd Su% $nd Module

bi 3:
Module Module1 Function Tong&an(ByVal n As Integer) As Dou%le Dim S As Dou%le Dim i As Integer For i = 1 To n Step 1 S = Mat+'=o?(i S4 1 2 (i 1)) !e"t #eturn S $nd Function Su% Main() Dim n As Integer Dim -. As Dou%le &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tong&an(n) &onsole'(rite)ine(*/et >ua , :0;*4 -.) $nd Su% $nd Module

bi 3A

Module Module1 Function Tong&an(ByVal n As Integer) As Dou%le Dim S As Dou%le Dim i As Integer Dim T As Integer = 1 For i = 1 To n Step 1 T = T 1 i S = Mat+'=o?(T S4 1 2 (i 1)) !e"t #eturn S $nd Function Su% Main() Dim n As Integer Dim -. As Dou%le &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tong&an(n) &onsole'(rite)ine(*/et >ua , :0;*4 -.) $nd Su% $nd Module

bi 40:

Module Module1 Function Tong&an(ByVal " As Single4 ByVal n As Integer) As Dou%le Dim S As Dou%le Dim i As Integer Dim T As Single = 1 For i = 1 To n Step 1 T = T 1 " S = Mat+'S.rt(T S) !e"t #eturn S $nd Function Su% Main() Dim n As Integer Dim " As Single Dim -. As Dou%le &onsole'(rite)ine(*!+ap Vao So ", *) " = &onsole'#ead)ine() &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tong&an("4 n) &onsole'(rite)ine(*/et >ua , :0;*4 -.) $nd Su% $nd Module

bi 41:

Module Module1 Function Tong=S(ByVal n As Integer) As Dou%le Dim S As Dou%le = 1 1 2 3 Dim i As Integer Dim T As Single = 1 For i = 3 To n Step 1 S = 1 1 2 S !e"t #eturn S $nd Function Su% Main()

Dim n As Integer Dim -. As Dou%le &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tong=S(n) &onsole'(rite)ine(*/et >ua , :0;*4 -.) $nd Su% $nd Module

bi 42 tB2 gi& tEL ! l(n nh#t )a< $h< S(!)Mn


Module Module1 Function Tong&an(ByVal n As Integer) As Dou%le Dim S As Integer Dim i As Integer For i = 1 To n Step 1 S = S i I9 S A= n T+en #eturn i 6 1 $nd I9 !e"t $nd Function Su% Main() Dim n As Integer Dim -. As Dou%le &onsole'(rite)ine(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tong&an(n) &onsole'(rite)ine(*So !guyen Duong T+oa , :0;*4 -.) $nd Su% $nd Module

bi 43 :012 )* l'4ng $hN )* $+a )* ng,-"n .'/ng


Module Module1 =u%lic Function DemS)(ByVal n As Integer) As Integer Dim D As Integer Dim T As Integer (+ile n BA 0 T = n Mod 10 I9 T BA 0 T+en D = D 1 $nd I9 n = n C 10 $nd (+ile #eturn D $nd Function Su% Main() Dim n As Integer Dim -. As Integer &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = DemS)(n) &onsole'(rite)ine(*So )uong &+u So , :0;*4 -.) $nd Su% $nd Module

bi 44 :Tnh Tng $&$ $hN )* $+a )* ng,-"n .'/ng


Module Module1 Function Tong&+uSo(ByVal n As Integer) As Integer Dim S As Integer Dim T As Integer (+ile n BA 0 T = n Mod 10 I9 T BA 0 T+en S = S T $nd I9 n = n C 10 $nd (+ile #eturn S $nd Function Su% Main() Dim n As Integer Dim -. As Integer &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tong&+uSo(n) &onsole'(rite)ine(*Tong &+u So , :0;*4 -.) $nd Su% $nd Module

bi 45 :Tnh T$h $&$ $hN )* $+a )* ng,-"n .'/ng


Module Module1 Function Tic+&+uSo(ByVal n As Integer) As Integer Dim T As Integer = 1 Dim Temp As Integer (+ile n BA 0 Temp = n Mod 10 I9 Temp BA 0 T+en T = T 1 Temp $nd I9 n = n C 10 $nd (+ile #eturn T $nd Function Su% Main() Dim n As Integer Dim -. As Integer &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tic+&+uSo(n) &onsole'(rite)ine(*Tic+ &ac &+u So , :0;*4 -.) $nd Su% $nd Module

bi 47 :012 )* l'4ng $hN )* l8 $+a )* ng,-"n .'/ng


Module Module1 Function DemSo)e(ByVal n As Integer) As Integer

Dim D As Integer Dim T As Integer (+ile n BA 0 T = n Mod 10 I9 T BA 0 T+en I9 T Mod 3 BA 0 T+en D = D 1 $nd I9 $nd I9 n = n C 10 $nd (+ile #eturn D $nd Function Su% Main() Dim n As Integer Dim -. As Integer &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = DemSo)e(n) &onsole'(rite)ine(*So )uong &+u So )e, :0;*4 -.) $nd Su% $nd Module

bi 49 :tnh Tng $&$ $hN )* $h6n $+a )* ng,-"n .'/ng


Module Module1 Function TongSo&+an(ByVal n As Integer) As Integer Dim S As Integer Dim T As Integer (+ile n BA 0 T = n Mod 10 I9 T BA 0 T+en I9 T Mod 3 = 0 T+en S = S T $nd I9 $nd I9 n = n C 10 $nd (+ile #eturn S $nd Function Su% Main() Dim n As Integer Dim -. As Integer &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = TongSo&+an(n) &onsole'(rite)ine(*Tong &+u So &+an, :0;*4 -.) $nd Su% $nd Module

bi 4: :tnh T$h $&$ $hN )* $h6n $+a )* ng,-"n .'/ng


Module Module1 Function Tic+So)e(ByVal n As Integer) As Integer Dim S As Integer = 1 Dim T As Integer (+ile n BA 0 T = n Mod 10

I9 T BA 0 T+en I9 T Mod 3 BA 0 T+en S = S 1 T $nd I9 $nd I9 n = n C 10 $nd (+ile #eturn S $nd Function Su% Main() Dim n As Integer Dim -. As Integer &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tic+So)e(n) &onsole'(rite)ine(*Tic+ &+u So )e, :0;*4 -.) $nd Su% $nd Module

bi 4A: tB2 $hN )* OP, ti"n $+a =


Module Module1 Function Tic+So)e(ByVal n As Integer) As Integer Dim S As Integer = 1 (+ile n A 10 n = n 2 10 $nd (+ile #eturn n $nd Function Su% Main() Dim n As Integer Dim -. As Integer &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tic+So)e(n) &onsole'(rite)ine(*&+u So Dau Tien, :0;*4 -.) $nd Su% $nd Module

bi 50: tB2 $hN $* O%< ng'4$ $+a )* ng,-"n .'/ng


Module Module1 =u%lic Function DemS)(ByVal n As Integer) As Integer Dim D As Integer Dim T As Integer (+ile n BA 0 T = n Mod 10 I9 T BA 0 T+en D = D 1 $nd I9 n = n 210 $nd (+ile #eturn D $nd Function Function /T!g+ic+Dao(ByVal n As Integer) As Integer Dim so As Integer = DemS)(n) Dim i As Integer Dim temp As Integer = 1 For i = 3 To so Step 1 temp = temp 1 10 !e"t

Dim / As Integer = n Dim S4 t As Integer (+ile / BA 0 t = / Mod 10 S = S t 1 temp / = / 2 10 temp = temp 2 10 $nd (+ile #eturn S $nd Function Su% Main() Dim n As Integer &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() Dim -. As Integer = /T!g+ic+Dao(n) &onsole'(rite(*So !g+ic+ Dao, :0;*4 -.) $nd Su% $nd Module

bi 51: tB2 $hN )* l(n nh#t $+a )* ng,-"n .'/ng


Module Module1 Function &+uSo)on!+at(ByVal n As Integer) As Integer Dim temp As Integer = 1 Dim T As Integer (+ile n BA 0 T = n Mod 10 I9 T A temp T+en temp = T $nd I9 n = n 2 10 $nd (+ile #eturn temp $nd Function Su% Main() Dim n As Integer Dim -. As Integer &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = &+uSo)on!+at(n) &onsole'(rite)ine(*&+u So )on !+at, :0;*4 -.) $nd Su% $nd Module

bi 51: tB2 $hN )* =h? nh#t $+a )* ng,-"n .'/ng


Module Module1 Function &+uSo!+o!+at(ByVal n As Integer) As Integer Dim temp As Integer = D Dim T As Integer (+ile n BA 0 T = n Mod 10 I9 T B temp T+en temp = T $nd I9 n = n 2 10 $nd (+ile #eturn temp

$nd Function Su% Main() Dim n As Integer Dim -. As Integer &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = &+uSo!+o!+at(n) &onsole'(rite)ine(*&+u So !+o !+at, :0;*4 -.) $nd Su% $nd Module

bi 53: 012 S3 $hN )* l(n nh#t $+a )* ng,-"n .'/ng


Module Module1 Function &+uSo!+o!+at(ByVal n As Integer) As Integer Dim temp As Integer = 1 Dim T As Integer Dim D As Integer Dim - = n (+ile - BA 0 T = - Mod 10 I9 T A temp T+en temp = T $nd I9 - = - 2 10 $nd (+ile (+ile n BA 0 T = n Mod 10 I9 T = temp T+en D = D 1 $nd I9 n = n 2 10 $nd (+ile #eturn D $nd Function Su% Main() Dim n As Integer Dim -. As Integer &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = &+uSo!+o!+at(n) &onsole'(rite)ine(*So )uong &+u So )on !+at, :0;*4 -.) $nd Su% $nd Module

bi 55 012 )l $hN )* OP, ti"n $+a )< ng,-"n .'/ng


Module Module1 Function SoDauTien(ByVal n As Integer) As Integer Dim S As Integer = 1 Dim t As Integer = n Dim temp4 D As Integer (+ile t A 10 t = t 2 10 $nd (+ile (+ile n BA 0 temp = n Mod 10 I9 temp = t T+en

D = D 1 $nd I9 n = n 2 10 $nd (+ile #eturn D $nd Function Su% Main() Dim n As Integer Dim -. As Integer &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = SoDauTien(n) &onsole'(rite)ine(*So )uong &+u So Dau Tien, :0;*4 -.) $nd Su% $nd Module

bi 57: !QR2 tEa )* =g,-"n .'/ng $@ t<n $hN )* l8 ha- !S


Module Module1 Function /TToan)e(ByVal n As Integer) As Integer Dim t As Integer = n Dim - As Integer (+ile t BA 0 - = t Mod 10 I9 - Mod 3 = 0 T+en #eturn 0 $nd I9 t = t 2 10 $nd (+ile #eturn 1 $nd Function Su% Main() Dim n As Integer Dim -. As Integer &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = /TToan)e(n) I9 -. = 1 T+en &onsole'(rite)ine(*Toan &+u So )e*) $lse &onsole'(rite)ine(*/+ong =+ai Toan )e*) $nd I9 $nd Su% $nd Module

bi 57: !QR2 tEa )* =g,-"n .'/ng $@ t<n $hN )* ;h6n ha- !S


Module Module1 Function /TToan&+an(ByVal n As Integer) As Integer Dim t As Integer = n Dim - As Integer (+ile t BA 0 - = t Mod 10 I9 - Mod 3 BA 0 T+en #eturn 0 $nd I9 t = t 2 10

$nd (+ile #eturn 1 $nd Function Su% Main() Dim n As Integer Dim -. As Integer &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = /TToan&+an(n) I9 -. = 1 T+en &onsole'(rite)ine(*Toan &+u So &+an*) $lse &onsole'(rite)ine(*/+ong =+ai Toan &+an*) $nd I9 $nd Su% $nd Module

bi 5A:!iT2 tEa )* ng,-"n .'/ng = $@ Fh%i l )* 0*i xUng !S


Module Module1 =u%lic Function DemS)(ByVal n As Integer) As Integer Dim D As Integer Dim T As Integer (+ile n BA 0 T = n Mod 10 I9 T BA 0 T+en D = D 1 $nd I9 n = n C 10 $nd (+ile #eturn D $nd Function Function /T!g+ic+Dao(ByVal n As Integer) As Integer Dim so As Integer = DemS)(n) Dim i As Integer Dim temp As Integer = 1 For i = 3 To so Step 1 temp = temp 1 10 !e"t Dim / As Integer = n Dim S4 t As Integer (+ile / BA 0 t = / Mod 10 S = S t 1 temp / = / C 10 temp = temp C 10 $nd (+ile #eturn S $nd Function

bi 70: HT )* =g,-Rn .'/ng (=)$@ tJng .Pn tV tE&i )ang Fh%i ha- !S
Module Module1 Function /TTangDan(ByVal n As Integer) As Integer Dim - As Integer = n Dim temp As Integer = - Mod 10 - = - 2 10

Dim t As Integer (+ile - BA 0 t = - Mod 10 I9 t A temp T+en #eturn 0 $lse temp = t $nd I9 - = - 2 10 $nd (+ile #eturn 1 $nd Function Su% Main() Dim n As Integer Dim -. As Integer &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = /TTangDan(n) I9 -. = 1 T+en &onsole'(rite)ine(*Tang Dan tu Trai Sang =+ai *) $lse &onsole'(rite)ine(*/+ong Tang Dan Tu Trai Sang =+ai *) $nd I9

bi 71: HT )* =g,-Rn .'/ng (=)$@ Wi%2 .Pn tV tE&i )ang Fh%i ha- !S
Module Module1 Function /TEiamDan(ByVal n As Integer) As Integer Dim - As Integer = n Dim temp As Integer = - Mod 10 - = - C 10 Dim t As Integer (+ile - BA 0 t = - Mod 10 I9 t B temp T+en #eturn 0 $lse temp = t $nd I9 - = - C 10 $nd (+ile #eturn 1 $nd Function Su% Main() Dim n As Integer Dim -. As Integer &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = /TEiamDan(n) I9 -. = 1 T+en &onsole'(rite)ine(*Eiam Dan tu Trai Sang =+ai *) $lse &onsole'(rite)ine(*/+ong Eiam Dan Tu Trai Sang =+ai *) $nd I9 $nd Su% $nd Module

bi 72 TB2 X($ ;h,ng 3(n =h#t


Module Module1 Function 8oc&+ung)on!+at(ByVal a As Integer4 ByVal % As Integer) As Integer

Dim t1 As Integer = a Dim t3 As Integer = % (+ile t1 BA t3 I9 t1 A t3 T+en t1 = t1 6 t3 $lse t3 = t3 6 t1 $nd I9 $nd (+ile #eturn t1 $nd Function Su% Main() Dim a4 % As Integer Dim -. As Integer &onsole'(rite(*!+ap Vao So a, *) a = &onsole'#ead)ine() &onsole'(rite(*!+ap Vao So %, *) % = &onsole'#ead)ine() -. = 8oc&+ung)on!+at(a4 %) &onsole'(rite)ine(*8oc &+ung )on !+at , :0;*4 -.) $nd Su% $nd Module

bi 73 tB2 CYi $h,ng nh? =h#t


Module Module1 Function Boi&+ung!+o!+at(ByVal a As Integer4 ByVal % As Integer) As Integer Dim t1 As Integer = a Dim t3 As Integer = % (+ile t1 BA t3 I9 t1 A t3 T+en t1 = t1 6 t3 $lse t3 = t3 6 t1 $nd I9 $nd (+ile Dim -. = a 1 % 2 t1 #eturn -. $nd Function Su% Main() Dim a4 % As Integer Dim -. As Integer &onsole'(rite(*!+ap Vao So a, *) a = &onsole'#ead)ine() &onsole'(rite(*!+ap Vao So %, *) % = &onsole'#ead)ine() -. = Boi&+ung!+o!+at(a4 %) &onsole'(rite)ine(*Boi &+ung !+o !+at , :0;*4 -.) $nd Su% $nd Module

bi 74 Wi%i ZT bK$ 1
Module Module1 Su% =TBac1(ByVal a As Integer4 ByVal % As Integer) I9 a = 0 T+en I9 % = 0 T+en &onsole'(rite)ine(*=+uong Trin+ Vo So !g+iem*) $"it Su% $lse &onsole'(rite)ine(*=+uong Trin+ Vo !g+iem*) $"it Su% $nd I9 $lse &onsole'(rite)ine(*!g+iem F= :0;*4 6% 2 a)

$nd I9 $nd Su% Su% Main() Dim a4 % As Integer &onsole'(rite(*!+ap Vao So a, *) a = &onsole'#ead)ine() &onsole'(rite(*!+ap Vao So %, *) % = &onsole'#ead)ine() =TBac1(a4 %) $nd Su% $nd Module

Ci 75 Wi%i ZT bK$ 2
Module Module1 Su% =TBac1(ByVal a As Integer4 ByVal % As Integer) I9 a = 0 T+en I9 % = 0 T+en &onsole'(rite)ine(*=+uong Trin+ Vo So !g+iem*) $"it Su% $lse &onsole'(rite)ine(*=+uong Trin+ Vo !g+iem*) $"it Su% $nd I9 $lse &onsole'(rite)ine(*!g+iem F= :0;*4 6% 2 a) $nd I9 $nd Su% Su% =TBac3(ByVal a As Integer4 ByVal % As Integer4 ByVal c As Integer) I9 a = 0 T+en =TBac1(%4 c) $lse Dim Delta As Dou%le = % 1 % 6 @ 1 a 1 c I9 Delta B 0 T+en &onsole'(rite)ine(*=+uong Trin+ Vo !g+iem*) $lseI9 Delta = 0 T+en &onsole'(rite)ine(*=+uong Trin+ &o !g+iem /ep F= :0;*4 6% 2 3 1 a) $lse &onsole'(rite)ine(*=+uong Trin+ &o 3 !g+iem CnF1= :0; F3=:1 ;*4 (6% Mat+'S.rt(Delta)) 2 3 1 a4 (6% 6 Mat+'S.rt(Delta)) 2 3 1 a) $nd I9 $nd I9 $nd Su% Su% Main() Dim a4 %4 c As Integer &onsole'(rite(*!+ap Vao So a, *) a = &onsole'#ead)ine() &onsole'(rite(*!+ap Vao So %, *) % = &onsole'#ead)ine() &onsole'(rite(*!+ap Vao So c, *) c = &onsole'#ead)ine() =TBac3(a4 %4 c) $nd Su% $nd Module

Ci 77 Wi%i ZT bK$ 4
Module Module1 Su% =TBac1(ByVal a As Integer4 ByVal % As Integer) I9 a = 0 T+en I9 % = 0 T+en &onsole'(rite)ine(*=+uong Trin+ Vo So !g+iem*) $"it Su%

$lse &onsole'(rite)ine(*=+uong Trin+ Vo !g+iem*) $"it Su% $nd I9 $lse &onsole'(rite)ine(*!g+iem F= :0;*4 Mat+'S.rt(6% 2 a)) $nd I9 $nd Su% Su% =TBac3(ByVal a As Integer4 ByVal % As Integer4 ByVal c As Integer) I9 a = 0 T+en =TBac1(%4 c) $lse Dim Delta As Dou%le = % 1 % 6 @ 1 a 1 c I9 Delta B 0 T+en &onsole'(rite)ine(*=+uong Trin+ Vo !g+iem*) $lseI9 Delta = 0 T+en &onsole'(rite)ine(*=+uong Trin+ &o !g+iem /ep F= :0;*4 6% 2 3 1 a) ;*4 (6% $lse &onsole'(rite)ine(*=+uong Trin+ &o 3 !g+iem CnF1= :0; Mat+'S.rt(Delta)) 2 3 1 a4 (6% 6 Mat+'S.rt(Delta)) 2 3 1 a) $nd I9 F3=:1

$nd I9 $nd Su% Su% =TBac@(ByVal a As Integer4 ByVal % As Integer4 ByVal c As Integer) I9 a = 0 T+en =TBac3(%4 04 c) $lse Dim Delta As Dou%le = % 1 % 6 @ 1 a 1 c I9 Delta B 0 T+en &onsole'(rite)ine(*=+uong Trin+ Vo !g+iem*) $lseI9 Delta = 0 T+en &onsole'(rite)ine(*=+uong Trin+ &o !g+iem /ep F= :0;*4 Mat+'S.rt (6% 2 3 1 a)) $lse &onsole'(rite)ine(*=+uong Trin+ &o 3 !g+iem CnF1= :0; F3=:1 ;*4 Mat+'S.rt((6% Mat+'S.rt(Delta)) 2 3 1 a)4 Mat+'S.rt((6% 6 Mat +'S.rt(Delta)) 2 3 1 a)) $nd I9 $nd I9 $nd Su% Su% Main() Dim a4 %4 c As Integer &onsole'(rite(*!+ap Vao So a, *) a = &onsole'#ead)ine() &onsole'(rite(*!+ap Vao So %, *) % = &onsole'#ead)ine() &onsole'(rite(*!+ap Vao So c, *) c = &onsole'#ead)ine() =TBac@(a4 %4 c) $nd Su% $nd Module

Ci 79 T[ng 3\- thVa


ZGZ ;<.R:
Module Module1 Function Tong)uyT+ua(ByVal " As Dou%le4 ByVal n As Integer) As Dou%le Dim S As Integer = 0 Dim T As Integer = 61 Dim i As Integer For i = 1 To n Step 1

T = T 1 6" S = S T !e"t #eturn S $nd Function Su% Main() Dim n As Integer Dim " As Dou%le Dim -. As Dou%le &onsole'(rite(*!+ap Vao So ", *) " = &onsole'#ead)ine() &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tong)uyT+ua("4 n) &onsole'(rite)ine(*/et >ua, :0;*4 -.) $nd Su% $nd Module

Ci 7: T[ng 3\- thVa *


Module Module1 Function Tong)uyT+ua(ByVal " As Dou%le4 ByVal n As Integer) As Dou%le Dim S As Integer = 0 Dim T As Integer = 1 Dim i As Integer For i = 3 To 3 1 n Step 3 T = T 1 6" 1 " S = S T !e"t #eturn S $nd Function Su% Main() Dim n As Integer Dim " As Dou%le Dim -. As Dou%le &onsole'(rite(*!+ap Vao So ", *) " = &onsole'#ead)ine() &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tong)uyT+ua("4 n) &onsole'(rite)ine(*/et >ua, :0;*4 -.) $nd Su% $nd Module

Ci 7A T[ng 3\- thVa **


Module Module1 Function Tong)uyT+ua(ByVal " As Dou%le4 ByVal n As Integer) As Dou%le Dim S As Integer = 0 Dim T As Integer = " Dim - = 1 Dim i As Integer For i = 1 To 3 1 n Step 3 T = - 1 (" 5 i) S = S T - = - 1 61 !e"t #eturn S $nd Function Su% Main() Dim n As Integer Dim " As Dou%le Dim -. As Dou%le &onsole'(rite(*!+ap Vao So ", *) " = &onsole'#ead)ine()

&onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tong)uyT+ua("4 n) &onsole'(rite)ine(*/et >ua, :0;*4 -.) $nd Su% $nd Module

Ci 90 T[ng Zh]n )*
Module Module1 Function Tong=+anSo(ByVal n As Integer) As Dou%le Dim S As Dou%le = 0 Dim T As Dou%le = 0 Dim i As Integer For i = 1 To n Step 1 T = 1 2 (T i) S = S T !e"t #eturn S $nd Function Su% Main() Dim n As Integer Dim -. As Dou%le &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tong=+anSo(n) &onsole'(rite)ine(*/et >ua, :0;*4 -.) $nd Su% $nd Module

;^3^_=5_R.5`Ci

Module Module1 Function Tong=+anSo(ByVal " As Integer4 ByVal n As Integer) As Dou%le Dim S As Dou%le = 0 Dim T As Dou%le = 1 Dim M As Integer = 0 Dim i As Integer For i = 1 To n Step 1 T = T 1 6" M = M i S = S T 2 M !e"t #eturn S $nd Function Su% Main() Dim n As Integer Dim "4 -. As Dou%le &onsole'(rite(*!+ap Vao So ", *) " = &onsole'#ead)ine() &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tong=+anSo("4 n) &onsole'(rite)ine(*/et >ua, :0;*4 -.) $nd Su% $nd Module

91aa/;^3^_`

Ci 92
Module Module1 Function Tong=+anSo(ByVal " As Integer4 ByVal n As Integer) As Dou%le Dim S As Dou%le = 0 Dim T As Dou%le = 1 Dim M As Integer = 1 Dim i As Integer For i = 1 To n Step 1

T = T 1 6" M = M 1 i S = S T 2 M !e"t #eturn S $nd Function Su% Main() Dim n As Integer Dim "4 -. As Dou%le &onsole'(rite(*!+ap Vao So ", *) " = &onsole'#ead)ine() &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tong=+anSo("4 n) &onsole'(rite)ine(*/et >ua, :0;*4 -.) $nd Su% $nd Module C

Ci 93
Module Module1 Function Tong=+anSo(ByVal " As Integer4 ByVal n As Integer) As Dou%le Dim S As Dou%le = 61 Dim T As Dou%le = 61 Dim M As Integer = 1 Dim i As Integer For i = 3 To 3 1 n Step 3 T = T 1 6" 1 " M = M 1 (i 6 1) 1 i S = S T 2 M !e"t #eturn S $nd Function Su% Main() Dim n As Integer Dim "4 -. As Dou%le &onsole'(rite(*!+ap Vao So ", *) " = &onsole'#ead)ine() &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tong=+anSo("4 n) &onsole'(rite)ine(*/et >ua, :0;*4 -.) $nd Su% $nd Module

Ci 94
Module Module1 Function Tong=+anSo(ByVal " As Integer4 ByVal n As Integer) As Dou%le Dim S As Dou%le = 1 6 " Dim T As Dou%le = 6" Dim M As Integer = 1 Dim i As Integer For i = 7 To 3 1 n 1 Step 3 T = T 1 6" 1 " M = M 1 (i 6 1) 1 i S = S T 2 M !e"t #eturn S $nd Function Su% Main() Dim n As Integer Dim "4 -. As Dou%le &onsole'(rite(*!+ap Vao So ", *) " = &onsole'#ead)ine()

&onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = Tong=+anSo("4 n) &onsole'(rite)ine(*/et >ua, :0;*4 -.) $nd Su% $nd Module

Ci 95
Module Module1 Function &+ia<et3Mu/(ByVal n As Integer) As Integer Dim t As Integer I9 n = 1 T+en #eturn 0 $nd I9 (+ile n A= 3 t = n Mod 3 n = n C 3 I9 t BA 0 T+en #eturn 0 $nd I9 $nd (+ile #eturn 1 $nd Function Su% Main() Dim n As Integer Dim -. As Dou%le &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = &+ia<et3Mu/(n) I9 -. = 1 T+en &onsole'(rite)ine(*&+ia <et &+o 3 5 /*) $lse &onsole'(rite)ine(*/+ong &+ia <et &+o 3 5 /*) $nd I9 $nd Su% $nd Module

Ci 97
Module Module1 Function &+ia<et7Mu/(ByVal n As Integer) As Integer Dim t As Integer I9 n = 1 Gr n = 3 T+en #eturn 0 $nd I9 (+ile n A= 7 t = n Mod 7 n = n C 7 I9 t BA 0 T+en #eturn 0 $nd I9 $nd (+ile #eturn 1 $nd Function Su% Main() Dim n As Integer Dim -. As Dou%le &onsole'(rite(*!+ap Vao So n, *) n = &onsole'#ead)ine() -. = &+ia<et7Mu/(n) I9 -. = 1 T+en &onsole'(rite)ine(*&+ia <et &+o 7 5 /*) $lse &onsole'(rite)ine(*/+ong &+ia <et &+o 7 5 /*)

$nd I9 $nd Su% $nd Module

You might also like