Have an idea?

Visit Sawtooth Software Feedback to share your ideas on how we can improve our products.

Generate a random number divisible by 3

Hello all,

I need a series of random numbers, 5 digits in length, that are divisible by 3. They will be dispalyed to survey respondents as validation codes. In the past, I would make codes in Excel and turn them into a Predefined list, and then call list members for each respondent based on their RespNum. Unfortunately, I need 20,000 random codes, and I keep freezing SSI Web by trying to paste that many items into a list.

Is there a way to use the RandNum or SysRand functions to generate numbers divisible by 3? I know I can use them to get 5-digit numbers (by setting Min and Max to 10000 and 99999).

Any help is much appreciated!
asked Jan 31, 2013 by cschlosser Bronze (1,005 points)
retagged Jan 31, 2013 by Walter Williams
Thank you, Bahadir and Aaron. I didn't realize I could add mathematical functions to the RandNum function. I appreciate the help!

2 Answers

0 votes
Hello, why don't you randomly generate 10000-33333 and then multiply by 3?
answered Jan 31, 2013 by Bahadir Ozkurt Gold (16,910 points)
Sorry, Bahadir! Didn't intend to copy your post - we must have both posted at the same time.
0 votes
Couldn't you just use SSI Script to choose a random number between 3334 and 33333, and then simply multiply it by 3?


answered Jan 31, 2013 by Aaron Hill Gold Sawtooth Software, Inc. (10,095 points)
Sorry, I forgot that you needed to specify a random seed.  The script would actually be [%RandNum(seed,3334,33333)%].  If you needed to select more than one five digit random number per respondent, you would put in multiple RandNum functions, each with a different seed.