Jump to content

# 1.7.2 Using an Arithmetic Sequence [SOLVED]

## Recommended Posts

How would I create an arithmetic sequence (fn = fn-1 + f) and implement it?

To explain more fully. I'm wanting an item to do something ever 10,000 ticks. I can make it do something at 10,000 and I can make it do it every number after that by manually entering the numbers in, but doing that for an infinite amount of time would... well... be impossible.

So, is there a way for me to use a fn = fn-1 + f sequence and then tell my if statement that if the ticks equal anything in that sequence then it should proceed?

I thought about for statements and arrays but I can't work out how it would work. Any help?

##### Share on other sites

What if you can't reset the counter?

I thought about doing it that way but the tick counter is needed for other things as well, so resetting it would screw that up.

##### Share on other sites

Do you just want to do something "every 10,000 ticks".

To do something every 10,000 ticks you just need a variable that is incremented every tick and then just check if it is evenly divisible by 10,000 (or whatever number you want).

Most programming languages have a "modululs" operator, sometimes called the "remainder" operator.  It tells you if something is evenly divisible if the remainder = 0.  In Java this operator uses the percent sign "%".  You can find out more here: http://www.cafeaulait.org/course/week2/15.html

So if you had an int variable called tick_count, you would know you're on a 10,000 x n tick with something like the following logical expression:

if (tick_count % 10000 == 0) {

// do your stuff here

}

Check out my tutorials here: http://jabelarminecraft.blogspot.com/

Ah, that did it

Thank you

## Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

### Announcements

×

• #### Activity

×
• Create New...

## Important Information

By using this site, you agree to our Terms of Use.