vb题目 编程:求最大化N,使N1<500

来源:百度知道 编辑:UC知道 时间:2024/09/24 13:41:45
谢谢大家 急求````作业啊````

'vb题目 编程:求最大化N,使N1<500
Imports System
Imports System.Collections.Generic
Imports System.Text

Namespace CSharp_Answers.Classes
Class BIGEST_N_
Public Shared Function NumUnderFactorial() As Integer
Dim i As Integer
i = 0
While Factorial(i) < 500
i += 1
End While
Return i - 1
End Function
Private Shared Function Factorial(ByVal N As Integer) As Integer
If N <= 0 Then
Return 0
ElseIf N = 1 Then
Return 1
Else
Return N * Factorial(N - 1)
End If
End Function
End Class
End Namespace

测试代码:

Imports System
Imports System.Collections.Generic
Imports System.Text
Imports CSharp_Answers.Cl