[[練習問題]]

 Sub 線形合同法()
 Dim m As Long
 Dim a As Long
 Dim b As Long
 Dim x As Long
 Dim x2 As Double
 Dim avg As Double
 Dim i As Integer
 m = 65536
 a = 997
 b = 1
 x = 12345
     For i = 1 To 100
         x = (a * x + b) Mod m
         x2 = x / m
         Cells(i, 1).Value = Format(x2, "0.0000")
     Next
 avg = Application.Average(Range("A:A"))
 avg = Application.WorksheetFunction.Average(Range("A:A"))
 Range("B1") = "平均" & Format(avg, "0.0000")
 End Sub

トップ   編集 差分 履歴 添付 複製 名前変更 リロード   新規 一覧 検索 最終更新   ヘルプ   最終更新のRSS