Properties
Similar Topics
Statistics
Comments
3
Participants
2
Subscribers
27
Votes
1
Views
2107
Share
Answered
I would like to create a list of n random different odd numbers in given interval using GeoGebra scripting (not Java Script) and honestly I have no idea how to do this with pure GGB scripting...
Any idea is more then welcome :-)
- GeoGebra
- Help
- Partners
-
Contact us
- Feedback & Questions
- This email address is being protected from spambots. You need JavaScript enabled to view it.
- +43 677 6137 2693
© 2023 International GeoGebra Institute
You can create a shuffled list of odd numbers between the given min and max and select the first n numbers.Od course you have to take care that n doesn't exceed the possible number of odd different numbers between min and max.
I added a try, using the command: First(Shuffle(Sequence(2n + 1, n, round(min / 2) - 1, round(max / 2) - 1)), n)
chris
I've found the solution with several lists: (1) list1 of all numbers in given interval, (2) list2A of all even numbers from list1 and list2B of all odd numbers from list1, (3) lists 3A and 3B that are shuffled lists 2A and 2B and then I take wanted n numbers from these lists...
I wonder if there's neater way to do this... ?
You can create a shuffled list of odd numbers between the given min and max and select the first n numbers.Od course you have to take care that n doesn't exceed the possible number of odd different numbers between min and max.
I added a try, using the command: First(Shuffle(Sequence(2n + 1, n, round(min / 2) - 1, round(max / 2) - 1)), n)
chris
Thanks ccambre!
I was obviously too tired last night and that's the reason why my brain was fried :wink: ... so I've honestly wrote I had no idea how to do it!
You've connected all three steps of my code ( the only thing that my brain could come up to last night :stuck_out_tongue_winking_eye: ) into one neat line of code!
Once again thanks and have a nice weekend.
Comments have been locked on this page!