• Welcome to Bashguru

    Linux is one of popular version of UNIX operating System. It is open source as its source code is freely available. It is free to use. Linux was designed considering UNIX compatibility. It's functionality list is quite similar to that of UNIX and become very popular over the last several years. Our Basic motive is to provide latest information about Linux Operating system.

  • Python Programming

    Python is a comparatively simple programming language, compared to c++. Although some of the benefits of c++ are abstracted away in python, they are replaced with an overall easier to learn language with many “intuitive” features. For this reason it is common and recommended by most professionals that people new to programming start with python.

  • Perl Programming

    Perl is an open-source, general-purpose interpreted programming language. Used often for CGI, Perl is also used for graphics programming, system administration, network programming, finance, bioinformatics, and other applications. The Perl languages borrow features from other programming languages including C, shell scripting (sh), AWK, and sed. They provide powerful text processing facilities without the arbitrary data-length limits of many contemporary UNIX command line tools, facilitating easy manipulation of text files.

  • Android

    Android is an operating system based on the Linux kernel, and designed primarily for touch screen mobile devices such as smart phones and tablet computers. Android is a Linux-based software system, and similar to Linux, is free and open source software. This means that other companies can use the Android operating developed by Google and use it in their mobile devices.Android gives you a world-class platform for creating apps and games for Android users everywhere, as well as an open marketplace for distributing to them instantly.

Monday, December 20, 2010

Posted by venu k
16 comments | 12:08 PM

#!/bin/bash
# SCRIPT: armstrong_bw_range.sh
# USAGE: armstrong_bw_range.sh
# PURPOSE: Finding Armstrong numbers between given range.
# \\\\ ////
# \\ - - //
# @ @
# ---oOOo-( )-oOOo---
#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. They are totalled and we get the original number again!
#Notice that Armstrong numbers are base dependent,but we'll mainly be
#dealing with base 10 examples.The Armstrong numbers up to 5 digits
#are 1 to 9,153, 370, 371, 407, 1634, 8208, 9474, 54748, 92727, 93084
#
#####################################################################
# Script Starts Here #
#####################################################################

echo -n "Enter the Lower Limit : "
read Start
echo -n "Enter the Upper Limit : "
read Ending

echo "Armstrong Numbers between $Start and $Ending are: "

while [ $Start -le $Ending ]
do
Number=$Start
Length=${#Number}
Sum=0
OldNumber=$Number

while [ $Number -ne 0 ]
do
Rem=$((Number%10))
Number=$((Number/10))
Power=$(echo "$Rem ^ $Length" | bc )
Sum=$((Sum+Power))
done

if [ $Sum -eq $OldNumber ]
then
echo -n "$OldNumber "
fi

let Start++
done
echo


OUTPUT:
# sh armstrong_bw_range.sh
Enter the Lower Limit : 1
Enter the Upper Limit : 500
Armstrong Numbers between 1 and 500 are:
1 2 3 4 5 6 7 8 9 153 370 371 407

# sh armstrong_bw_range.sh
Enter the Lower Limit : 1000
Enter the Upper Limit : 10000
Armstrong Numbers between 1000 and 10000 are:
1634 8208 9474

16 comments:

  1. gud page!
    n itz xtremely useful for beginners like me..!

    ReplyDelete
  2. Armstrong numbers are---->
    1 2 3 4 5 6 7 8 9 153 370 371 407 1634 8208 9474 54748 92727 93084 548834 1741725 4210818 9800817 9926315 24678050 24678051 88593477 146511208 472335975 534494836 912985153 etc.

    ReplyDelete
  3. 1 to 9 armstrong numbers.........????
    How.....???????/

    ReplyDelete
    Replies
    1. This comment has been removed by the author.

      Delete
    2. A number N is an Armstrong number of order n (n being the number of digits)
      if
      abcd. . . = a^n + b^n + c^n + d^n .+ ...= N
      so in case of 1 to 9 number of digit is 1 so 1^1 = 1 ..... but 10 has two digit => 1^2 + 0^2 != 10 ,,,,,

      Delete
  4. I was growing up. At first, kids don't venture far from the home base tree. When they get older, faster, more confident of their surroundings, they venture further. nikon coolshot 20

    ReplyDelete
  5. Brilliant stuff! This was hilarious and so well written. I really loved it :)

    ReplyDelete
  6. The information you share is very useful to me, thank you so much for the article

    ReplyDelete
  7. Very good, I think I found the knowledge I needed

    ReplyDelete
  8. There are a few shrouded costs in a payday credit! Keep in mind, in the event that you can't pay this loan and you happen to lose your activity, the clock does not stop. auto title loans near me chicago

    ReplyDelete
  9. Hi i am from dodopackaging.Wonderful Blog! I should need to thank for the undertakings you have made in creating this post. I am confiding in a comparable best work from do my coursework uk later on as well. I expected to thank you for this destinations! Thankful for sharing.
    product packaging

    ReplyDelete