Archive for July, 2012

Multiplying Recurring Decimals

Let’s get to the heart of it right away, and pick a totally non-arbitrary number, 7, just because it’s my favorite one-digit number. The reciprocal (or multiplicative inverse) of 7 can be written in decimals as the following shows:

The bar on top of the 142857, also called a vinculum, marks these digits as being recurring (see repeating decimals), meaning that 

an that, to infinity (or for eternity, if you actually try to calculate it).


Do you see something strange about 142857? It starts with 14, then adds 28 (14×2), then it almost has 56 (14×4). But try to calculate the next number, and you get 112 (14×8). If you add the first few numbers, you get the following:

which is summed as


As you do more and more iterations, more digits are fixed and the result gets closer and closer to the expected value (it converges towards that value). For example, the next iteration (…3584) will fix the 39 at the end of the sum to the correct 42. And so on and so forth.


Are there any other numbers that have the same property? After all, this seems like a pretty weird coincidence.

Actually, all numbers’ reciprocals behave as such. Hn hnnn, it’s true! More to follow.


Are there any other sum of numbers that will yield the recurring 142857? To be honest, the previous addition seems like luck, or like there’s something alien about it.

Actually, it would seem alien to anyone who has not studied number theory, I guess. There are an infinity of such sums that give you a recurring 142857. I need to repeat that: an infinity of such sums exist.


To make the rest of the post easier to read, let’s define these sums. In the previous example, you begin with 14, and then multiply it repeatedly by 2, moving your position (precision) by two each time. We can “encrypt” that precision (position moving on each iteration) in the starting value: 14 means you move by two, and 014 means you move by three. I could then write the above sum as 14××2 (I couldn’t find a suitable, untaken character for this).

So, what other sums can give you 142857 for infinity? How about 142××6? Try it out! Then try 1428××4, then 14285××5, and 142857××1. Also, don’t forget to check 1××3, and 1428571××3. Right there, you can see that you can have an infinity of possible sums.

Although they’re based on the same numbers, it’s still interesting, right? No, it gets better. A lot. Try 13××9. Honestly. Pick a piece of paper and try it. Here, let me help you with it:


Granted, it converges slowly, but you can easily see that, given some more iterations, you get the expected value. (In fact, the farther you are from ××1, the slower it converges.)

Now, try 12××16, and 11××23. You can already see a trend, right? Down to 01××93.

Let me also add 2××-4, and 15××-5. Up to 28××-96. Then I could pick random ones, like 087××391, or 1431××-17.

Yes, all of them converges to a recurring 142857.


If you list them all, it’s pretty easy to find a general formula:

where k is the precision, v is the arbitrary integer number you want to start with, and 0 < v < 2×10^k/7. It’s that easy! For example, if you want a number with three digits of precision (k), you can take any initial value v that is between 1 and 285 (2×1000/7). v = 0 results in a division by zero, and other values make the series diverge. Actually, you can do the same with negative values of v, except that the result is negative.

Remember when I talked about numbers different than 7 having the same property? You probably noticed (or wondered) if the 7 in the general formula above can be replaced by i, which would be the source of the reciprocal. Let’s define the new general equation more formally:


And what’s incredible with that, is that every reciprocal can be calculated that way. You have your i value at the start (the reciprocal you want),  then arbitrarily choose any precision (k) and multiplier (v), and you have an equation that matches a set of recursive numbers to infinity.

Categories: Science, Thinking Tags:

Travelling Around the World, part 1 of 2

I had an idea today.

Suppose I wanted to travel for an extended period of time, let’s say between six months and a year.

Let’s estimate how much six months would cost. We could put an upper limit of 100$ per day, including lodging and food. Some countries would cost a lot less, some others would cost more. That’s 3,000$ per month, or 18,000$ for six months. 36,000$ for a complete year. The total amount would most likely be less if I’m careful, but I think it’s safe to say that chances are it would cost less. Also, I wouldn’t be paid by my company during this long trip, so the actual cost to me would be even higher (I still have to pay my apartment’s bills).

My options would be:

  • save for many years;
  • win a substantial amount of money;
  • work locally during the travel;
  • generate a lot of interest for this trip by the community.


This post is, of course, about the fourth option. After all, I would seriously screw my retirement plans after saving for so long, and winning money is not really up to me. Working locally during the travel is still interesting, but gives only a few hours of sightseeing at the end of the day, and what happens when you realize you can only find work one day out of three?

Generating a lot of interest for this trip by the community is the idea I had. Being paid to travel sounds like an awesome idea, and is possible in this era of information.

Picture this for a second. I wake up in the morning on a stranger’s couch. I contacted him the day before through the couchsurfing website. I leave his place and log on foursquare to find a nice place to eat breakfast, and check-in there. I go to tripadvisor for an idea of a good place to go, then go to an internet cafe to eat lunch, while booking a hotel room in my next city using the HotelsByMe application. During the day, depending on network connections, I post on my google+ and twitter to keep the community up-to-date. Since this is a nice day, I walk the 38km to that hotel, go back to foursquare to find a place to eat dinner, check-in at the hotel, play the tourist and take pictures. Before going to bed, I blog about my day on wordpress, upload my pictures to my dropbox account for a backup, post the best ones on Google Photos and facebook, and plan some itineraries with tripit and Google Maps / OpenStreetMap for the next day. Maybe post on reddit if I saw something out of the ordinary. All that with a smartphone and a tablet.

This is, of course, totally in contrast to a “disconnected trip”. I would be almost constantly updating my whereabouts and doings to the Internet, and logging everything. For this to work (financially), I would need interest from the community – a following. People who would log to my blog everyday to read what I have to say about my current location, about the food I eat, about the accents, etc. They would come to read someone’s view of the world and its small places, because they can’t go themselves.

Let’s dream a bit: suppose I have about a million hits on my blog every month – about 35,000 every day. That would be potentially enough to generate 3,000$ or 4,000$ per month in ad revenue, which is enough to go by easily during the trip. Add to that some donations by users, and we’re in business.


What I had in mind was to show the finances relating to the trip on a website. People would go there and comment on things I’ve done, or suggest places for me to go. They could come and say “Hey, you’re in my city in five days! Come over, we’ll go to a nightclub, and you’ll stay on the couch to sleep.” Given a large enough following, I could find a friendly place to stay a third of the time, a couchsurfee another third, and a hotel the rest of the time. In a tent if I’m in the middle of nowhere. That could possibly reduce the price per day to an average of, say, 50$?

I could call that “Community Travel“, but I think I like “Open-Source Travelling” better. After all, it’s something everyone can contribute to, freely.

In the second part, I’ll check the pro and cons of doing such a project.

Categories: Thinking, Traveling

Lotteries – Additional Prizes

Last post of a trilogy about the Lotto Max lottery in Canada. First post, second post.


In the first two posts, we saw that the Canadian Lotto Max lottery wasn’t very profitable, and in a good day, you could expect a return of 40% (0.40$ per dollar spent, or 0.66$ per ticket (1.67$ each)). What we didn’t discuss is the Maxmillion prizes.

In Lotto Max, the jackpot is capped at 50,000,000$. When the total prize is higher, Maxmillion prizes are added. They are 1,000,000$ prizes that have their own set of numbers, thus increasing your chances (1:85,900,584 per Maxmillion) of winning an amount of money.

Does adding Maxmillions change anything?


Again, this depends on how many tickets were sold. If two people have the same winning numbers for a Maxmillion prize, the Maxmillion is split. The same calculations than in the second post reveal that, for 35,000,000 tickets sold, we can expect to win 821,341.59$ (66% chances of winning alone, 27% chances of splitting the prize with someone, etc…).

So, dividing the expected amount by our odds, 821,341.59$ / 85,900,584, gives us an added expected return of a cent (0.009562$) per ticket. Not really interesting, right?


Last week’s draw has 28 Maxmillion prizes and almost exactly 35,000,000 tickets sold, bringing my expected return to 0.94$ per ticket, about 56% return. Better, but still…

But wait a minute! Last draw’s jackpot was still not won, and this week’s draw (2012-07-06) will offer 50 Maxmillion prizes, which I’ve never seen so high. I’m eager to see if the number of tickets sold will stabilize at around 15,000,000 (according to my graph in the second post), and if it does, it will bring my expected return to about 1.12$ per ticket, about 67%.


Which means that, this week, you can expect to lose only a third of what you pay. That’s better than buying a ticket for a 10,000,000$ jackpot, from which you could expect a return of about 10 cents.


All these calculations show that, following the trends, roughly 120 Maxmillion prizes would be needed if you would want your expected return to be better than your spending. Though if we reach 120 such prizes, there’s something wrong with statistics, because the jackpot should have been won a long time ago, thus resetting the number of Maxmillion prizes!


To give an update on my 30-tickets buying spree for last week, I won 40$ and a free play, so a return of 90%. I was a bit lucky, I guess! I bought tickets with the return, plus 10$ worth of them, so 33 tickets in all. That sounds like a lot, but isn’t really. Many people spend more every week on cigarettes alone, which have an expected return of 0.00$ and only health troubles.


One of Steve Pavlina’s post was of particular interest. It talked about intention and manifestation (that and many later posts). This is my intention: “I intent that an interesting amount of money manifests to me in the near future.

Let’s see how this week’s draw turns out. According to my calculated expected return, I can expect 37$ back (from 55$ worth of tickets).

Categories: Thinking Tags:

Lotteries – Splitting a Prize

Second post of a trilogy about the Lotto Max lottery in Canada. First post, last post.


The previous post talked about your expected return on a single ticket. This is valid only if you’re the only one playing. As more and more people buy tickets, there are more and more chances that a particular combination was bought by multiple people. For example, if the jackpot is 40,000,000$, and there are two people with the correct combination, they each receive 20,000,000$. This is true for all the prizes that are from the “pool funds”. The other fixed prizes are, well, fixed.

In the graph, we see the initial normal trend – as the jackpot rises, more and more people buy tickets. The data was taken for 1.5 years. As we’ll see in the last post, Lotto Max’s jackpot limit is set to 50,000,000$, the rest being in the form of 1,000,000$ prizes. This seems to have the effect of preventing more sales, since everyone only see the big 50M$ prize, and don’t really care about the smaller millions. Another way to look at it is that people buy tickets only to have a chance at the jackpot, not for the overall expected return.



For simplicity in the following paragraphs, let us define p to equal 85,900,584. This is the number of ticket possibilities, so 1-p is the odds of winning the jackpot.

If you play alone, the jackpot has 1 : p odds of being won. If you and only one other person play, the jackpot’s odds of being won are almost doubled. For n tickets sold, you can know the odds that one ticket only was winning

The middle part tells us that one person won (probability of winning = 1/p). The last part shows that all the other persons didn’t win (probability of not winning = p-1/p). Then, you multiply it by the number of tickets, because it could have been player 2 who won, or player 3, or player 6,321,552.

But what are the odds of both of you having the same winning number? In that case, there are two people who has a 1/p chance to win, and nobody to lose. The first part is a bit trickier. In the last example, there were n possible ways for the players to win. Now, since you and the other person are winning and only the two of you bought tickets, there is only one possible way to organize the results, so you multiply by 1.

The generic formula for this is, given n tickets and k winners:

The first part is how many possible combinations of k winners among n players. It uses the formula


On a side note, if you would want to know the odds that n tickets would yield at least l winners (instead of exactly k), you would have to add them one by one:


Back to Reality

Now that we have some formulas to work with, what are the odds that you win the jackpot, but there’s some inconsiderate killjoy who also wins?

Let’s assume that there were 10,000,001 tickets sold. It is assumed that you already win – the calculations are then for 10,000,000 tickets. Using the generic formula, with n = 10,000,000 and k = 1 (we are looking for only one other person who won), we find that the odds are 10.36%. That bastard!

Similarly, the odds that there are two killjoys (out of the the other 10,000,000 tickets) are 0.60%.

These odds are dependent on the number of tickets sold. For 50,000,000 tickets, the odds are 32.52% and 9.47%, respectively.


For Lotto Max, on a good week, there can be about 35, 000,000 tickets sold (10 to 12 million plays). Let’s assume that the pool funds is 60,000,000$ (so the jackpot is 50,000,000$, or 87% of the 60,000,000$, maxed at 50,000,000$), and that there are 35,000,000 tickets sold. My expected return, only considering the jackpot, would not be 0.58$ per ticket (0.35$ per dollar “invested”), because some other people might win.

The following table shows how much I can expect to win in a jackpot (assuming I do win), based on how many other people also won.

Others Odds Jackpot Share Part of the Expected Return
0 66.535% 50,000,000$ 33,267,500$
1 27.109% 25,000,000$ 6,777,250$
2 5.523% 16,666,667$ 920,500$
3 0.75% 12,500,000$ 93,750$
4 0.076% 10,000,000$ 7,600$
5 0.006% 8,333,333$ 500$
6+ < 0.001%
Total 100% 41,067,100$

That’s it! For a jackpot of 50,000,000$ and 35,000,000 tickets sold, my expected jackpot would be 41,067,100$, giving me an expected return of 0.48$ per ticket, or 0.29$ per spent dollar.


If we look at the table from last post to account for some killjoys that were born to ruin our fun, instead of having an expected return of 0.48$ per dollar spent, it is closer to 0.40$ per dollar. For example, with so many circulating tickets, the 700,000$ allocated to the 6/7B category could easily be split among a few people. In fact, you can expect to receive 231,263.75$, not 700,000$. Since the lower prizes are fixed, there is no splitting, though.


If the jackpot is 50,000,000$, ans there are 35,000,000 tickets, your expected return is 0.66$ per ticket, or 0.40$ per dollar spent.


If that was all, this would be a terrible lottery, but all is not lost. In the last post, I will bring forth the power of the mathematics on Lotto Max’s Maxmillions.

Categories: Thinking Tags:

Lotteries – The Basics

Second post of a trilogy about the Lotto Max lottery in Canada. Second post, last post.


I was reading a post by DC Woods, saying he buys lottery tickets even though he is a statistician. I wanted to build upon his idea with some of mine, and to show the numbers for a popular lottery game in Canada – Lotto Max.

Lotto Max draws seven numbers from one to forty-nine. It costs five dollars for a “play” (three tickets). You win a prize depending on how many good numbers you have on your ticket. There is a bonus number that can help you win other prizes.

You can calculate the odds of winning a certain prize, given a set of numbers (one ticket). All the mathematics are explained in the Lottery mathematics wikipedia page. The following table has all the data we need to continue, and the columns are explained right after.

Type Odds Prize Winnings
0/7 26,978,328
0/7nB 22,481,940
0/7B 4,496,388
1/7 36,720,502
1/7nB 31,474,716
1/7B 5,245,786
2/7 17,864,028
2/7nB 15,737,358
2/7B 2,126,670
3/7 3,917,550
3/7nB 3,544,450 Free play N/A
3/7B 373,100 20$ 7,462,000$
4/7 401,800 20$ 8,036,000$
4/7nB 373,100
4/7B 28,700
5/7 18,081 5% ~875,000$
5/7nB 17,220
5/7B 861
6/7 294
6/7nB 287 4% ~700,000$
6/7B 7 4% ~700,000$
7/7 1 87% ~50,000,000$
Total 85,900,584 100% ~67,773,000$

The Type column defines all the categories that a ticket can fall into. If it has, for example, six numbers right plus the bonus number, it goes into the 6/7B category. If you only have the six numbers right, but not the bonus number, it goes into the 6/7nB category. Some categories don’t care if you have the bonus number or not, so that’s the row without a “nB” or “B”.

If you bought every ticket combination (please don’t do that), the Odds column would be how many of your tickets would go into each category.

2.40$ from every play sale is allocated to “prize fund”. The “pool fund” is calculated by subtracting the fixed prices from the prize fund, using 2.40$ for the price of a free play. The Prize column shows what you could expect to win in each ticket category. The percentage represent the fraction of the pool funds allocated to a category, but the amount can change significantly if it wasn’t won the previous week

The Winnings column shows how much you could expect to win if you bought every possible ticket combination. Again, the prize in a category can greatly change depending on the sales and previous weeks’ results. The column is shown with a jackpot of fifty million dollars and a plausible distribution of the pool funds.

On a side note, the odds of winning anything with a single ticket are 4,337,726 : 85,900,584, or 1 : 19.8.


According to the table, if we bought every possible tickets, we could reasonably expect to win 68,000,000$, give or take a few millions. Buying all these tickets would cost us 143,167,640$, so our expected return would be 0.48$. Bluntly (don’t be mad), it means that for every dollar you spend, you could get 0.48$ back on average. This is terrible, even for lotteries. You can get much better odds in casinos.

I think it’s interesting and noteworthy to say that this 0.48$ expected return is based on a 50,000,000$ jackpot. If you buy a ticket for a 10,000,000$ jackpot, your expected return will be closer to 0.10$.


There are two more concepts that need to be explained, which will be in my next two posts about lotteries.

The next post will be about the odds of you splitting your prize with another person, which could greatly make your expected return fall.

The last post will be about Maxmillions, Lotto Max’s additional prizes, which could make your expected return more interesting.

Categories: Thinking Tags: