#!/usr/bin/perl

# (C) 2010 Ole Tange <ole@tange.dk>
# 

# This file is protected by copyright. It is illegal to download it
# without a license. You can buy a license priced at 1100000000 DKK.
# If you do not buy a license your download will cause the value of
# the unauthorized copying in Denmark to rise by 1100000000 DKK for
# every download.

lucky(shift,0);

sub lucky {
    my($i,$n) = @_;
    if($i <= 1 or $n>100) {
	print "You were lucky $n times\n";
	exit;
    }
    if($i % 2) {
	return unlucky($i+1,$n);
    } else {
	return unlucky($i/2,$n);
    }
}

sub unlucky {
    my($i,$n) = @_;
    if($i % 3) {
	return lucky($i+33,$n+1);
    } else {
	return lucky($i / 3, $n+1);
    }
}
    
