开发者

Pyramid scheme formula in PHP?

I'm working on a referral system - the formula is exactly like the pyramid/ponzi scheme.

The system works like this:

The initial user signs up (tier 1)

The initia开发者_StackOverflow社区l user refers 3 friends (tier 2)

Each of those 3 friends refer another 3, (tier3)

etc.

What would be the mathematical formula for that?

How could I code up something in PHP where I could enter a number and it will then give me the number of tiers it has gone down and a semi-visual.

ie: I enter 13 - it displays the text "3 tiers" and then displays

     o
     |
    ooo
   / | \
 ooooooooo


This is a geometric progression (GP), each tier's count is multiplied by a constant number (3) i.e. 1, 3, 9, 27 etc. You are concerned with the sum of the progression.

Read a simplified explanation about GP here. http://www.intmath.com/series-binomial-theorem/2-geometric-progressions.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜