detective1711

Câu d: Ước số

Dec 3rd, 2012
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.79 KB | None | 0 0
  1. Private Sub CmdInput1_Click(sender As Object, e As EventArgs) Handles CmdInput1.Click
  2.         Dim n As Long
  3.         Dim i As Long
  4.         Dim tong As ULong
  5.         Dim count As Integer
  6.         Dim ax As String
  7.         tong = 0
  8.         count = 0
  9.         Do While n <= 0
  10.             n = InputBox("Vui lòng nhập vào một số nguyên dương", "Nhập", 0)
  11.         Loop
  12.         For i = 1 To n
  13.             If n Mod i = 0 Then
  14.                 tong = tong + i
  15.                 Count = Count + 1
  16.                 If i Mod 2 = 0 Then
  17.                     ax = ax + "   " & i
  18.                 End If
  19.             End If
  20.         Next
  21.         TxtOut12.Text = "Tổng các ước số: " & tong & vbCrLf & "Số các ước số:" & count & vbCrLf & "Các ước số chẵn : " & ax
  22.     End Sub
Advertisement
Add Comment
Please, Sign In to add comment