You are on page 1of 4

Sub pr_1()

n = Val(InputBox(" citeste n: "))


suma = 0
For i = 1 To n
suma = suma + i ^ 2
Next
MsgBox suma
End Sub
Sub pr_2()
n = Val(InputBox("citeste n: "))
prod = 1
For i = 1 To n
prod = prod * i
Next
MsgBox prod
End Sub
Sub pr_10()
Dim n As Integer
Dim k As Integer
n = Val(InputBox("citeste n: "))
k = Val(InputBox("citeste k: "))
nfact = 1
For i = 1 To n
nfact = nfact * i
Next
kfact = 1
For i = 1 To k
kfact = kfact * i
Next
nkfact = 1
For i = 1 To (n - k)
nkfact = nkfact * i
Next
MsgBox "combinari de n luate cate k este: " + Str(nfact / (nkfact * kfact)) + " iar aranjamente de n luate cate k este:
" + Str(nfact / nkfact)
End Sub
Sub pr_3()
Dim n As Integer

Dim i As Integer
Dim a As Integer
Dim b As Integer
n = InputBox("n: ")
For i = 1 To n
If i ^ 2 < n Then
a=a+1
End If
If i ^ 3 < n Then
b=b+1
End If
Next
MsgBox "numarul patratelor perfecte mai mici decat n este " + Str(a)
MsgBox "numarul cuburilor perfecte mai mici decat n este" + Str(b)
End Sub
Sub pr_4()
Dim n As Integer
Dim s As Double
Dim s1 As Double
Dim fact As Double
n = InputBox("dati n:")
E=1
fact = 1
s=0
s1 = 0
For i = 1 To n
E = 1 / (i * (i + 1))
s=s+E
Next
MsgBox "prima suma are valoarea:"
MsgBox s
For i = 1 To n
fact = fact * (i + 1)
Next
MsgBox fact
For i = 3 To n
E = ((i ^ 2 - i - 1) ^ 2 - 2) / fact
s1 = s1 + E
Next
MsgBox "a doua suma are valoarea: "
MsgBox s1
p=1

For i = 1 To n
E = 1 + 1 / (2 * i - 1)
p=p*E
Next
MsgBox "podusul are valoarea: " + Str(p)
End Sub
Sub pr_9()
Dim n As Integer
n = InputBox("dati n: ")
Dim a As Integer, b As Integer, c As Integer
For a = 1 To 100
For b = 1 To 100
For c = 1 To 100
If n = a + b + c Then
MsgBox Str(a) + Str(b) + Str(c)
End If
Next
Next
Next
End Sub
Sub pr_11()
Dim n As Integer
Dim a As Integer, b As Integer, c As Integer, d As Integer
For n = 1000 To 9999
a = Left(n, 1)
b = Mid(n, 2, 1)
c = Mid(n, 3, 1)
d = Right(n, 1)
If d < c And b - c = a And b Mod 3 = 0 And d Mod 3 = 0 Then
MsgBox Str(a) + Str(b) + Str(c) + Str(d)
End If
Next
End Sub
Sub pr_12()
Dim n As Integer
Dim a As Integer, b As Integer, c As Integer, d As Integer
For n = 1000 To 9999

a = Left(n, 1)
b = Mid(n, 2, 1)
c = Mid(n, 3, 1)
d = Right(n, 1)
If a > b And b > c And c > d And a * d = (b * c) / 2 Then
MsgBox Str(a) + Str(b) + Str(c) + Str(d)
End If
Next
Sub pr_14()
Dim a As Integer, b As Integer
Dim n As Integer
n = InputBox("dati n")
For a = 1 To n - 1
For b = 1 To n - 1
s=a+b
MsgBox "(" + Str(a) + "," + Str(b) + ")" + " si suma este" + Str(s)
Next
Next
End Sub
Sub pr_16()
Dim n As Integer
Dim i As Integer
Dim s As Integer
n = InputBox("dati n:")
s=0
For i = 1 To n
If i Mod 5 = 0 Then
s=s+i
End If
Next
MsgBox Str(s)
End Sub

You might also like