Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

'divisible by' help: how do you write 'a number is divisible by 6'?

Explorer ,
Mar 23, 2012 Mar 23, 2012

Hi. I have a timer going, that i want to reactivate every time the score is divisible by 6.

so, i wrote

public var number:uint;

if(score==number/6)

{

     number = 6;

     timer.start();

}

but that is wrong.

Can anyone help me write the notion of a number being divisible by 6.

thanks:)

TOPICS
ActionScript
8.4K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

LEGEND , Mar 23, 2012 Mar 23, 2012

You can use the modulus operator, which produces the remainder after dividing by a number...

    if(number%6 == 0){

that being true says the number is divisible by 6

Translate
LEGEND ,
Mar 23, 2012 Mar 23, 2012

You can use the modulus operator, which produces the remainder after dividing by a number...

    if(number%6 == 0){

that being true says the number is divisible by 6

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 23, 2012 Mar 23, 2012

I don't know what your variables mean but you can see if a number is evenly divisible by another number using mod:

if(score % 6 == 0){

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Mar 23, 2012 Mar 23, 2012

Aw, Ned ya beat me - same minute even!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Mar 23, 2012 Mar 23, 2012

thanks folks!!

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Mar 23, 2012 Mar 23, 2012
LATEST

You're welcome

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines