How to count how many times a number generates
-
- Prole
- Posts: 1
- Joined: Sat Feb 16, 2019 1:51 am
How to count how many times a number generates
So I am fairly new to LOVE and for a program I'm doing I'm have to create a for loop that runs a million times and generates random values between 0 -32. My only issue is trying to get program to count how many times each number was generated. If anyone could help, it would be much appreciated.
Re: How to count how many times a number generates
Hi, and welcome to the forums You just need to create a table with an entry for each possible number from 0 to 32, initially all zeros. That's easily done with a loop from 0 to 32. These are the counters, one for each number. Then you run the other loop, the one that repeats a million times, where you draw a number from 0 to 32 and add 1 to the counter for that number.
What to do with that table after the loop is up to you You can for example print the values on the terminal with another loop from 0 to 32.
What to do with that table after the loop is up to you You can for example print the values on the terminal with another loop from 0 to 32.
Who is online
Users browsing this forum: Google [Bot] and 3 guests