This evening, I received an email showing me several beauty of math numbers, that fascinated me.
This email of Beauty of Math Numbers is not really related to my linux blog. However, my attempt for tracing the DNA relation of this beauty of math numbers to linux family genes has been successful for the past few minutes and I would like to share it here.
A set of number patterns will be shown one at a time and I would try to achieve the same effect using simple bash scripting as we move along live.
I have to copy and paste from the email that I received.
Here goes the first contestant of the Beauty of Math in Linux.
1 x 8 + 1 = 9
12 x 8 + 2 = 98
123 x 8 + 3 = 987
1234 x 8 + 4 = 9876
12345 x 8 + 5 = 98765
123456 x 8 + 6 = 987654
1234567 x 8 + 7 = 9876543
12345678 x 8 + 8 = 98765432
123456789 x 8 + 9 = 987654321
See the pretty number patterns above?
Now here's goes my freshly made linux bash script to achieve the same mathematical computation and match display shown above:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#/bin/bash
x=1
constant=8
array=(1 12 123 1234 12345 123456 1234567 12345678 123456789)
while [ $x -lt 10 ] ;
do
let product=${array[$x-1]}*$constant+$x
echo ${array[$x-1]} x $constant + $x = $product
let x=$x+1;
done
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Screen Output:
1 x 8 + 1 = 9
12 x 8 + 2 = 98
123 x 8 + 3 = 987
1234 x 8 + 4 = 9876
12345 x 8 + 5 = 98765
123456 x 8 + 6 = 987654
1234567 x 8 + 7 = 9876543
12345678 x 8 + 8 = 98765432
123456789 x 8 + 9 = 987654321
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Now, the second contestant for the Beauty of Math using Linux bash scripting.
1 x 9 + 2 = 11
12 x 9 + 3 = 111
123 x 9 + 4 = 1111
1234 x 9 + 5 = 11111
12345 x 9 + 6 = 111111
123456 x 9 + 7 = 1111111
1234567 x 9 + 8 = 11111111
12345678 x 9 + 9 = 111111111
123456789 x 9 +10= 1111111111
And here's my equivalent bash script for that
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#/bin/bash
x=2
constant=9
array=(1 12 123 1234 12345 123456 1234567 12345678 123456789)
while [ $x -lt 11 ] ;
do
let product=${array[$x-2]}*$constant+$x
echo ${array[$x-2]} x $constant + $x = $product
let x=$x+1;
done
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Output:
1 x 9 + 2 = 11
12 x 9 + 3 = 111
123 x 9 + 4 = 1111
1234 x 9 + 5 = 11111
12345 x 9 + 6 = 111111
123456 x 9 + 7 = 1111111
1234567 x 9 + 8 = 11111111
12345678 x 9 + 9 = 111111111
123456789 x 9 + 10 = 1111111111
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Now, the third contestant from the Beauty of Math in Linux:
9 x 9 + 7 = 88
98 x 9 + 6 = 888
987 x 9 + 5 = 8888
9876 x 9 + 4 = 88888
98765 x 9 + 3 = 888888
987654 x 9 + 2 = 8888888
9876543 x 9 + 1 = 88888888
98765432 x 9 + 0 = 888888888
which has an equivalent bash script code shown below:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#/bin/bash
x=7
y=0
constant=9
array=(9 98 987 9876 98765 987654 9876543 98765432)
while [ $y -lt 8 ] ;
do
let product=${array[$y]}*$constant+$x
echo ${array[$y]} x $constant + $x = $product
let x=$x-1;
let y=$y+1;
done
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Equivalent screen output:
9 x 9 + 7 = 88
98 x 9 + 6 = 888
987 x 9 + 5 = 8888
9876 x 9 + 4 = 88888
98765 x 9 + 3 = 888888
987654 x 9 + 2 = 8888888
9876543 x 9 + 1 = 88888888
98765432 x 9 + 0 = 888888888
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Brilliant isn't it?
Now, take a look at this next math symmetry.
1 x 1 = 1
11 x 11 = 121
111 x 111 = 12321
1111 x 1111 = 1234321
11111 x 11111 = 123454321
111111 x 111111 = 12345654321
1111111 x 1111111 = 1234567654321
11111111 x 11111111 = 123456787654321
111111111 x 111111111= 12345678987654321
Here goes its equivalent bash script for the above patterns:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
#/bin/bash
x=0
array=(1 11 111 1111 11111 111111 1111111 11111111 111111111)
while [ $x -lt 9 ] ;
do
let product=${array[$x]}*${array[$x]}
echo ${array[$x]} x ${array[$x]} = $product
let x=$x+1;
done
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
which has an equivalent terminal output:
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 x 1 = 1
11 x 11 = 121
111 x 111 = 12321
1111 x 1111 = 1234321
11111 x 11111 = 123454321
111111 x 111111 = 12345654321
1111111 x 1111111 = 1234567654321
11111111 x 11111111 = 123456787654321
111111111 x 111111111 = 12345678987654321
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Numerical Final Note:
~~~~~~~~~~~~~~~~~~~~
Numbers are interesting human-made and human-readable values that makes us real busy these computing days.
Any ideas who won this Beauty of Match Linux contest?
PS
Oh, I wonder how my black coffee with brandy (scotch coffee) helps me interpret these numbers into its equivalent bash script somehow.
Hope you enjoy reading them, cheers!
Categories
- HowTos (611)
- Linux Devices (39)
- Linux Diggs (620)
- Linux News (1541)
- Linux Videos (24)
Recent Posts
Blog Archive
-
►
2008
(2302)
-
►
October
(140)
- Linus Torvalds on Linux Distributions
- AMD to Spin off Manufacturing Operations
- MySQL cofounder David Axmark leaving Sun
- Mono to contribute back to CLI; Microsoft says it ...
- Monitor your network with GroundWork Monitor Commu...
- The LXF Guide: Write a Perl module
- 8 Best First-person Shooter Games for Linux
- AppDeploy Community Launches Free Windows Installe...
- Ubuntu Tweak - Sneak Peak at Latest Version!
- POS stack targets Linux netbooks
- RIP LinuxWorld
- Firefox extension blocks dangerous Web attack
- Wikia co-founder to speak at linux.conf.au
- Wikia co-founder to speak at linux.conf.au
- Look Ma, No ‘X’
- Look Ma, No ‘X’
- Forget the damn Linux netbooks. Can Windows replac...
- Forget the damn Linux netbooks. Can Windows replac...
- Amarok 2.0 Beta 2 was released
- 6 Years As A Professional Software Developer
- Amarok 2.0 Beta 2 was released
- 6 Years As A Professional Software Developer
- Distribution Release: EnGarde Secure Linux 3.0.21
- Torvalds talks about his brand new blog
- Become a multimedia pro with the Vector Linux Mult...
- Linux Robot - Watch This Space
- Distribution Release: EnGarde Secure Linux 3.0.21
- Torvalds talks about his brand new blog
- Become a multimedia pro with the Vector Linux Mult...
- Linux Robot - Watch This Space
- Linux-Based E-Voting In Brazil
- Is .NET on Linux Finally Ready?
- Linux-Based E-Voting In Brazil
- Multi-core networking stack ported to PowerPC
- Google rev's photo editor for Linux
- Project releases version 2.0 of open source .Net
- One more 2.6.27 prepatch
- Stallman vs. Clouds
- How to Create and Use a Password Reset Disk in Win...
- OpenOffice.org Grows Up
- 45+ Sources and Sets of Photoshop Custom Shapes
- Clean up your filesystems with fslint
- NPX-9000 UMPC is inexpensive but underpowered
- Will Chrome Find a Home With SaaS?
-
►
October
(140)
Friday, September 14, 2007
Beauty of Math using Linux
Subscribe to:
Post Comments (Atom)
ILoveTux - howtos and news | About | Contact | TOS | Policy


0 comments:
Post a Comment