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?
What do you call it when you loop around and arbitary number?
-
- 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?
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.
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.
-
- 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?
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.
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.