# A little math question

**URL:** <https://forum.kirupa.com/t/a-little-math-question/224613>\
**Category:** Uncategorized\
**Created:** [May 3, 2007, 6:49pm UTC](https://forum.kirupa.com/t/a-little-math-question/224613 "2007-05-03T18:49:42Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![inadequateanima](https://avatars.discourse-cdn.com/v4/letter/i/a87d85/32.png) [@inadequateanima](https://forum.kirupa.com/u/inadequateanima)\
**Post date:** [May 3, 2007, 6:49pm UTC](https://forum.kirupa.com/t/a-little-math-question/224613/1 "2007-05-03T18:49:42Z")

</div>

I’m using a piece of randomizing code for loading jpegs into a movie, and I wanted to change the math function so that on loading the window a random file is loaded, and then each successive button click loads the next file in sequence. For example, when the window opens a random function decides that 03.jpg will be shown, then when a button is clicked it loads 04.jpg, then 05.jpg etcetera.  
The code I am using so far is:

filename = [“01.jpg”, “02.jpg”, “03.jpg”, “04.jpg”, “05.jpg”, “06.jpg”, “07.jpg”, “08.jpg”, “09.jpg”];  
path = “pictures/topleft/”;  
i = filename.length;  
k = Math.floor(Math.random()\*i);  
loadMovie(path+filename[k], topleftloader);

However this results in a lot of repetition. Oftentimes a reload brings up the same image.  
Any advice would be much appreciated!  
Thanks.
