Advertisement
31ph4n70m

Neumann's_Random_Generator.vb

Dec 18th, 2019
654
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 1.07 KB | None | 0 0
  1. 'VisualBasic solution to codeabbey challenge 24
  2. Imports System
  3.  
  4. Module compiler
  5.    
  6.     Sub Main()
  7.         Dim inp1 As Integer = 12
  8.         Dim inp2() As Integer = {3488, 373, 5368, 751, 8342, 3416, 843, 6173, 7019, 381, 1054, 6303}
  9.         Dim counter As Integer = 1
  10.         Dim a, aux As Integer
  11.         Dim aux2 As Integer
  12.         Dim rsp() As String = {}
  13.         Dim vals() As Integer = {}
  14.         For Each a In inp2
  15.             aux = a
  16.             While true
  17.                 aux2 = Fix((aux * aux / 100) MOD 10000)
  18.                 If Array.IndexOf(vals, aux2) <> -1 Then
  19.                     ReDim Preserve rsp(rsp.Length)
  20.                     rsp(rsp.Length-1) = counter.ToString()
  21.                     Exit While
  22.                 End If
  23.                 ReDim Preserve vals(vals.Length)
  24.                 vals(vals.Length-1) = aux
  25.                 counter += 1
  26.                 aux = aux2
  27.             End While
  28.             counter = 0
  29.             Array.Clear(vals,0,vals.Length)
  30.         Next
  31.         Console.WriteLine (String.Join(" ", rsp))
  32.     End Sub
  33. end Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement