Pascal's Modified Triangle
Jump to navigation
Jump to search
Take any two numbers: p and q, and output this sequence:
20p + 20q 21p + 21q ...
Example Program
C#
internal class Program
{
private static void Main(string[] args)
{
long q = int.Parse(Console.ReadLine());
long p = int.Parse(Console.ReadLine());
long i = 0;
long sum = (2 ^ i) * q + (2 ^ i) * p;
while (true)
{
sum = (2 ^ i) * q + (2 ^ i) * p;
i++;
Console.WriteLine(sum);
}
}
}
Iterate
(*)1<
*?< (1*)<> > // p
*?< (2*)<> > // q
*∞<
$5 *=1< (5*)<> > *=2< (5*)<> > // p + q
*1< (3*)=5< *~n< &3 > @ > > // print total
*1< (3*)10< *~n< &3 > ~@ > > // newline
$5 *=1< *2< (5*)<> > >
$6 *=1< *2< (6*)<> > >
$1 *=5< (1*)<> >
$2 *=6< (2*)<> >
>
>