# what is Marital numbers code in ActionScript 3

Printable View

• 12-16-2017, 05:13 PM
kofa
what is Marital numbers code in ActionScript 3
hi
what is Marital numbers and odd numbers code in ActionScript 3

Marital numbers is : 0 2 4 6 8 10 12 .....
odd numbers is : 1 3 5 7 9 11 13 ....

i want do this :

var i:Marital numbers = Math.randomRange(0,20)
var h:odd numbers = Math.randomRange(0,20)
• 12-18-2017, 01:12 AM
kofa
how can i do this :

var i:Marital numbers = Math.randomRange(0,20)
var h:odd numbers = Math.randomRange(0,20)
i > h ( " i " must be > "h")
• 12-18-2017, 01:21 AM
swak
If you're trying to randomly generate an even or an odd number there's a simple way to do it. Basically just create a recursive function that will keep calling itself until it gets the proper number. This is a dirty way to do it however. Another way would be to use the original random number generator function. It basically generates a number between 0 to 1. With that you'd have to multiply it by the max number. Then you can round the number to the closes proper value. This is how I'd handle it.

Edit: to your second question.
Code:

`i > h ( " i " must be > "h")`
This would be a starting point. It could be a problem if i is ever = to 20 however.
Code:

`hdd numbers = Math.randomRange(i,20)`
• 12-18-2017, 10:51 AM
kofa
thanks swak you always help me
but i am sorry
because my bad english language i dont understand your replay
can you please edit my file

http://b.up-00.com/2017/12/151360848932691.jpg
• 12-20-2017, 11:40 AM
kofa
i found this link but i tired to get any thing:

http://lab.kapit.fr/skin/frontend/de.../MathUtil.html
• 12-24-2017, 06:08 PM
swak
I can't use swish. So I can't open your 'math code.swi' file. If you could point me to a Swish installer I could use then that would be different but it seems broken.

Also, Marital in english has to do with marriage. So using that word here is confusing. After looking at things it looks like you mean the word 'even'. If you're confused by a word I suggest you use the search in google like this: "define: marital".

I've created something that should do it:
Code:

```function generateNum(range:Array, isEven:int=0):int {         //isEven should be == 0 for even numbers and == 1 for odd         var num:Number = range[0]+Math.random()*range[1];         return (int(num)%2==isEven?Math.floor(num):Math.ceil(num)); } var even:int = generateNum([0,20],0); var odd:int = generateNum([0,even],1);```
The only problem with this is if even becomes 0. It will end up with both even and odd being 0.
• 12-29-2017, 08:28 AM
kofa
• 12-30-2017, 02:39 AM
kofa
thanks swak
now it working fine
and excuse me for my bad english language
• 01-01-2018, 05:15 AM
swak
No problem, the link you supplied didn't work. It was shortened. Could you fix it please?
• 01-01-2018, 04:37 PM
kofa
• 01-01-2018, 05:54 PM
swak
Thanks, that got it working.
• 01-02-2018, 04:13 AM
kofa
my respect for you swak