Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Simple algebra problem

  1. Oct 12, 2006 #1
    Hi Everyone! I've been a member for a while, but I've been away...

    It's good to be back though- I hope i find everyone well!

    I have an algebra question for a program i'm writing. I'm looking for a simple algebraic formula which can cope with any changes to the noOfCrystals & noOfColours variables.

    #### an example

    noOfCrystals = 8
    noOfColours = 4 [red, green, blue, black)

    change Colours every 2 crystals

    if (crystal ==1) or (crystal ==2) colour = red
    if (crystal ==3) or (crystal ==4) colour = green
    if (crystal ==5) or (crystal ==6) colour = blue
    if (crystal ==7) or (crystal ==8) colour = black

    #### another time it might read:

    noOfCrystals = 9
    noOfColours = 3 [red, green, blue)

    change Colours every 3 crystals

    if (crystal ==1) or (crystal ==2) or (crystal ==3) colour = red
    if (crystal ==4) or (crystal ==5) or (crystal ==6) colour = green
    if (crystal ==7) or (crystal ==8) or (crystal ==9) colour = blue

    does this make sense? I am extremely grateful for any help!

    Sean
     
  2. jcsd
  3. Oct 12, 2006 #2

    CRGreathouse

    User Avatar
    Science Advisor
    Homework Helper

    noOfCrystals = 8
    noOfColours = 4
    c[1] = red
    c[2] = green
    c[3] = blue
    c[4] = black
    colour = c[rounddown(crystal * noOfColours / noOfCrystals)]
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Have something to add?



Similar Discussions: Simple algebra problem
  1. Algebra Problem (Replies: 3)

  2. Algebra problem (Replies: 3)

  3. Algebra Problem (Replies: 3)

Loading...