I installed the LuaZM application for the Prizm and tried to run code for a factorial program with it.

Code:

    function fact (n)
      if n == 0 then
        return 1
      else
        return n * fact(n-1)
      end
    end
   
    print("enter a number:")
    a = io.read("*number")
    print(fact(a))

Unfortunately every time I run this the error message
---
Lua\factorial.lua:11: attempt to index global 'io' (a nil value)
---
appears and prevents it from executing. I have little programming experience, but I thing it means the io.read() function isn't defined or something similar. If anyone can tell me what bits of code I'm missing that would be awesome.
Please note that, even though LuaZM is the Lua interpreter, standard libraries may not be included. You should look into the Lua zmg documentation.
I didn't see any functions there that accepted input of numbers or strings and assigned them to a variable. Are there any in the current library?
Ygyaxthe3rd wrote:
I didn't see any functions there that accepted input of numbers or strings and assigned them to a variable. Are there any in the current library?


No, unfortunately, not yet.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 1 of 1
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement