Linux Tips and Tricks

Linux Tips and Tricks

Hoax Message – December 2012 – 5 Saturdays, 5 Sundays and 5 Mondays

November27

There is a Hoax message spreading out in emails. Stating that,

Circulating message claims that December 2012 will feature 5 Saturdays, 5 Sundays and 5 Mondays, a combination of days that occurs only once every 823 years. The message claims that sending on the information will bring good luck to the sender.

Brief Analysis
It is perfectly true that December 2012 has 5 Saturdays, 5 Sundays and 5 Mondays. However, such a combination occurs far more often than every 823 years. The last occurrence was in December 2007 while the next occurrence will take place in December 2018. In fact, any month that has 31 days will have three consecutive days that occur five times in the month. Such combinations are commonplace and occur each and every year. This message is a revamped version of earlier – and equally spurious – chain messages.

Thanks to http://www.hoax-slayer.com/december-2012-money-bags.shtml

Lets find out the years that has 5 Saturdays, 5 Sundays, 5 Mondays

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$ for i in {1900..2050}; do cal 12 $i|awk 'NR==1{year=$NF}NR==3&&NF==1{print year;exit}'; done
1900
1906
1917
1923
1928
1934
1945
1951
1956
1962
1973
1979
1984
1990
2001
2007
2012
2018
2029
2035
2040
2046

 

 

 

posted under Uncategorized | No Comments »

Armstrong number using awk command

November27

Armstrong number

Also known as narcissistic numbers, Armstrong numbers are the sum of their own digits to the power of the number of digits. As that is a slightly brief wording, let me give an example:

153 = 1³ + 5³ + 3³

Each digit is raised to the power three because 153 has three digits.

The  below code is used to find out the Armstrong numbers upto 2000. you can simply increase the value in {1..2000}

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
for i in {1..2000};do echo $i | awk '{a=0;l=length($0);for(i=1;i<=l;i++){a+=$i^l}if(a>$0)exit}$0==a{print}' FS= ; done
1
2
3
4
5
6
7
8
9
153
370
371
407
1634
posted under Uncategorized | No Comments »

Recent Comments

    Categories