Advertisement
31ph4n70m

Fibonacci_Divisibility_Advanced.vb

Nov 25th, 2019
768
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
VB.NET 0.89 KB | None | 0 0
  1. 'VisualBasic solution to codeabbey challenge 71
  2. Imports System
  3.  
  4. Module compiler
  5.     Function Getidxfib(ByVal m As Integer) As Integer
  6.         Dim fib1, fib2, fib3, idx As Integer
  7.         fib1 = 0
  8.         fib2 = 1
  9.         fib3 = 0
  10.         idx = 2
  11.         While true
  12.             fib3 = (fib1 + fib2) MOD m
  13.             If (fib3 MOD m = 0) Then
  14.                 return idx
  15.             End If
  16.             fib1 = fib2
  17.             fib2 = fib3
  18.             idx = idx + 1
  19.         End While
  20.     End Function
  21.    
  22.     Sub Main()
  23.         Dim ncases As String = 19
  24.         Dim cases() As Integer = {449825, 940999, 891051, 674588, 241652, 1049193, 1024240, 857743, 408165, 641261, 349920, 1015891, 982578, 291607, 657942, 374884, 508055, 458138, 732856}
  25.         Dim a As Integer
  26.         For a = 0 To ncases-1
  27.             Console.WriteLine (Getidxfib(cases(a)))
  28.         Next
  29.     End Sub
  30. end Module
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement