What do you call it when you loop around and arbitary number?

General project discussion. NOT for help questions.
Post Reply
lucid
Forum Members
Forum Members
Posts: 29
Joined: Mon Nov 12, 2007 2:48 pm

What do you call it when you loop around and arbitary number?

Post by lucid »

I'm stuck on a little programing script which basically counts to 3 and then goes back to 1 when it's done.
e.g. 1 = 1
      2 = 2
      3 = 3
      4 = 1

It's not really % or mod cause that would give
e.g. 1 = 1
      2 = 2
      3 = 0
      4 = 1

any ideas anyone?
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: What do you call it when you loop around and arbitary number?

Post by calguy1000 »

Read the smarty manual.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm

Re: What do you call it when you loop around and arbitary number?

Post by calguy1000 »

Besides the fact that this is completely irrelevant to a content management system, that there are thousands of other places on the web that you could've asked this TRIVIAL question, and that you didn't explain any context (like what language you were trying to write it in). I thought I'd just give a small example of a solution.

Code: Select all

for( i = 0; i < 100000; i++ )
{
   n = i %3;
   printf("%d\n",n+1);
}
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
Post Reply

Return to “General Discussion”