Messing around with infinity II
Years ago while messing around with infinity there were several weird results that came up.
Now check this out, we'll define the following mathematical formula that takes in two numbers "a" and "b" (assume that b>=a for simplicity), here it is:
So function "F" takes two numbers a and b. First, it finds out the products of all the numbers from a to b. Then it finds out the sum of all the numbers from a to b. Adds them up. Takes the factorial of the result.
One can easily implement this function, like this implementation below (C#):
class Program
{
static void Main(string[] args)
{
long a = Int64.Parse(args[0]);
long b = Int64.Parse(args[1]);
Console.WriteLine("F({0},{1}) = {2}", a, b, Function(a, b));
}
static long Factorial(long n)
{
long ret = 1;
for (long i = 2; i <= n; i++)
ret *= i;
return ret;
}
static long Function(long a, long b)
{
long product = 1;
long sum = 0;
for (long i = a; i <= b; i++)
{
product *= i;
sum += i;
}
return Factorial(product + sum);
}
}
Now check this out, we'll define the following mathematical formula that takes in two numbers "a" and "b" (assume that b>=a for simplicity), here it is:
So function "F" takes two numbers a and b. First, it finds out the products of all the numbers from a to b. Then it finds out the sum of all the numbers from a to b. Adds them up. Takes the factorial of the result.
One can easily implement this function, like this implementation below (C#):
class Program
{
static void Main(string[] args)
{
long a = Int64.Parse(args[0]);
long b = Int64.Parse(args[1]);
Console.WriteLine("F({0},{1}) = {2}", a, b, Function(a, b));
}
static long Factorial(long n)
{
long ret = 1;
for (long i = 2; i <= n; i++)
ret *= i;
return ret;
}
static long Function(long a, long b)
{
long product = 1;
long sum = 0;
for (long i = a; i <= b; i++)
{
product *= i;
sum += i;
}
return Factorial(product + sum);
}
}
If you run few tests you'll see that the function grows very fast. When running the function for a=0 and b=1, you get as the result 1. But for a=0 and b=5, the result grows to 1307674368000. Quite a jump.
But what is special about this function? The special thing is that if you feed it covering ALL THE NUMBERS saying from a=-infinity to b=+infinity, the result is.... 1 (one):
And it is not hard to see why:
- The product from a to b will pass thru 0 (zero), hence becoming 0
- The sum from -N to +N will be zero
- Factorial of zero is...1 (one)
Actually the result does not need to necessarily be -oo to +oo, same result happens for any -N to +N. But adding infinity gives it a nice touch! :) Many cheers, Marcelo.
Comments
Post a Comment