vb.net - Recursive factorial output -


i'm trying write recursive function through vb console application output factorial or number between 1 , 10. system.stackoverflowexception when run it. can explain i've done wrong?

module module1 dim number byte sub main()      console.writeline("write number 1-10")     number = console.readline()      factorialcalc()  end sub function factorialcalc()      dim counter byte      dim byte     ' dim factorial integer              if number < 1 or number > 10             console.writeline("please select number 1-10")         end if      loop until number >= 1 , number <= 10      = number              factorialcalc = number * factorialcalc(number - 1)         counter = counter + 1     loop until counter = + 1      console.writeline(factorialcalc.value)     console.readline()  end function end module 

a factorial program shouldn't long. need is:

module module1     dim number integer      sub main()                     console.writeline("write number 1-10")             number = console.readline()         loop until number >= 1 , number <= 10          dim result = factorialcalc()          console.writeline(result)         console.readline()     end sub      function factorialcalc(num integer) integer         return num * if(num > 2, factorialcalc(num - 1), 2)     end function end module 

Comments

Popular posts from this blog

apache - PHP Soap issue while content length is larger -

asynchronous - Python asyncio task got bad yield -

javascript - Complete OpenIDConnect auth when requesting via Ajax -