Ok, I have never used Ruby before and I'm trying to figure out how to convert my following Perl code into Ruby to do exactly what is does now.
Basically I used a loop structure to produces the following output (user can specify how many lines need to be printed):
A
AA
AAA
AAAB
AAABA
AAABAA
AAABAAA
AAABAAAB
#!/usr/bin/perl
print "Please enter your name: ";
$name = <STDIN>;
print "Please enter your favorite number: ";
$f = <STDIN>;
$a = 0;
if ($f < 0)
{
while ($f <0)
{
print "Please enter a positive number: ";
$f =<STDIN>;
}
}
{
while ($a < $f)
{
print $name;
$b = $a + 1;
$a = $b;
}
}