Kentaro Kuribayashi's blog

Software Engineering, Management, Books, and Daily Journal.

How Many Days Required until All Your Blog are Belong to Hatena Blog?

Hatena Blog gives us 1 invitation right per day. How long will it be all the people on the earth start using Hatena Blog when they always invite everyday those who haven't started Hatena Blog?

#!/usr/bin/env perl
use strict;
use warnings;

sub all_your_blog_are_belong_to_us {
    my ($blog_count, $days, $limit) = @_;
    if ($blog_count >= $limit) {
        say $days;
    }
    else {
        all_your_blog_are_belong_to_us($blog_count * 2, ++$days, $limit);
    }
}

all_your_blog_are_belong_to_us(1, 1, 7_000_000_000);

Only 34 days!