# Simple algebra problem

1. Oct 12, 2006

### sean123

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. Oct 12, 2006

### CRGreathouse

noOfCrystals = 8
noOfColours = 4
c[1] = red
c[2] = green
c[3] = blue
c[4] = black
colour = c[rounddown(crystal * noOfColours / noOfCrystals)]