Get only Odd numbers from a Sequence

0 favourites
  • 5 posts
From the Asset Store
Jump on numbers in the proper order and reach the sun!
  • Hello!

    My problem here is: I have an table with about 100 numbers, going from 1 to 100, and from these numbers, I only want to get the Odd ones, like 1,3,5,7,9,11,13,15...

    The problem is, it will randomly select an number from that sequence with the code: round(random(1,100)), and I want it to convert any Even numbers to Odd numbers, or to only generate Odd numbers from 1,100.

    And no, I don't wanna switch to Even, I must stay in Odd to have good code performance and to avoid bugs.

    Any help for the solution of this problem will be appreciated!

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • -> System: Set oddNumber to round(random(1,100))

    -> System: Set oddNumber to oddNumber%2=0 ? oddNumber+1 : oddNumber

    If oddNumber is even it adds 1 to the even number or it gives back the odd number

  • Is it all the odd numbers from 1 to 100?

    int(random(50))*2+1

    Or is it a different set of odd numbers?

  • Is it all the odd numbers from 1 to 100?

    int(random(50))*2+1

    Or is it a different set of odd numbers?

    Any Odd number from 1 to 100, because I have an .txt file that has 100 types of |, the Even | has X value, while the Odd | has Y value, I could already make an function for the Even one, I just needed one for the Odds.

  • -> System: Set oddNumber to round(random(1,100))

    -> System: Set oddNumber to oddNumber%2=0 ? oddNumber+1 : oddNumber

    If oddNumber is even it adds 1 to the even number or it gives back the odd number

    OH YES I FORGOT ABOUT REPEATING THE SENTENCE, DAMN! That should work, gotta test it, while testing the ROJO's one too, thank you all sirs, for helping me!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)