• 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.

Wednesday, December 22, 2010

Posted by venu k
39 comments | 12:38 PM
  By definition in mathematics, the Fibonacci Numbers are the numbers
in the below sequence:
0,1,1,2,3,5,8,13,21,34,55,89,144, ......
By definition, the first two Fibonacci numbers are 0 and 1, and each
subsequent number is the sum of the previous two. Some sources omit
the initial 0, instead beginning the sequence with two 1s.
In mathematical terms, the sequence Fn of Fibonacci numbers is defi-
ned by the recurrence relation
Fn = Fn-1 + Fn-2,
with seed values
F0 = 0 and F1 = 1.

Iterative Method:


#!/bin/bash#!/bin/bash
# SCRIPT: fibo_iterative.sh
# USAGE: fibo_iterative.sh [Number]
# PURPOSE: Generate Fibonacci sequence.
# \\\\ ////
# \\ - - //
# @ @
# ---oOOo-( )-oOOo---
#
#####################################################################
# Script Starts Here #
#####################################################################

if [ $# -eq 1 ]
then
Num=$1
else
echo -n "Enter a Number :"
read Num
fi

f1=0
f2=1

echo "The Fibonacci sequence for the number $Num is : "

for (( i=0;i<=Num;i++ ))
do
echo -n "$f1 "
fn=$((f1+f2))
f1=$f2
f2=$fn
done

echo

OUTPUT:
# sh fibo_iterative.sh 18
The Fibonacci sequence for the number 18 is :
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584
# sh fibo_iterative.sh
Enter a Number :20
The Fibonacci sequence for the number 20 is :
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610 987 1597 2584 4181 6765

Recursive Method:


#!/bin/bash
# SCRIPT: fibo_recursive.sh
# USAGE: fibo_recursive.sh [Number]
# PURPOSE: Generate Fibonacci sequence.
# \\\\ ////
# \\ - - //
# @ @
# ---oOOo-( )-oOOo---
#
#####################################################################
# Arguments Checking #
#####################################################################

if [ $# -eq 1 ]
then
Num=$1
else
echo -n "Enter a Number : "
read Num
fi

#####################################################################
# Define Functions Here #
#####################################################################

Fibonacci()
{

case $1 in
0|1) printf "$1 " ;;
*) echo -n "$(( $(Fibonacci $(($1-2)))+$(Fibonacci $(($1-1))) )) ";;
esac

#$(( )) construct is used instead of expr command for doing addition.
#$( ) constrict is used instead of back ticks.

}

#####################################################################
# Main Script Starts Here #
#####################################################################

echo "The Fibonacci sequence for the number $Num is : "

for (( i=0; i<=$Num; i++ ))
do
Fibonacci $i #Calling function Fibonacci
done

echo

OUTPUT:
# sh fibo_recursive.sh
Enter a Number : 11
The Fibonacci sequence for the number 11 is :
0 1 1 2 3 5 8 13 21 34 55 89
# sh fibo_recursive.sh 13
The Fibonacci sequence for the number 13 is :
0 1 1 2 3 5 8 13 21 34 55 89 144 233

Be aware that recursion is resource-intensive and executes slowly,
and is therefore generally not appropriate to use in a script.

[root@localhost shell]# time ./fibo_iterative.sh 15
The Fibonacci sequence for the number 15 is :
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610

real 0m0.008s
user 0m0.008s
sys 0m0.000s
[root@localhost shell]# time ./fibo_recursive.sh 15
The Fibonacci sequence for the number 15 is :
0 1 1 2 3 5 8 13 21 34 55 89 144 233 377 610

real 0m7.875s
user 0m0.908s
sys 0m5.188s

Too many levels of recursion may crash a script with a segfault.


39 comments:

  1. Hi,

    Thanks for sharing. Just to share my own version too:

    fibo() { local a=0; b="$1"; inc="$2"; while ((b < $inc)); do tmp=$((a+b)); a=$b; b="$tmp"; printf '%s ' "$tmp"; done; }; fibo 34 2000

    Regards,

    Valentin

    ReplyDelete
    Replies
    1. Hi Venu,

      Thanks so much for this article! I tried to follow some instructions from few other article and got in over my head. This worked so quickly and your instructions were very easy to follow. Really appreciate this.
      The environment where I’m working is a java application, and the complete sentence is “Career HSSE: (2345.65-point(s) HSSE)”, but UiPath identifies the section where the sentence is as an image.
      I scrap because I want to extract this number to compare with another scraped from another application.
      Its web base management platforms that enable remote control management and centralizing scheduling robot and processing.
      I extracted all the sentence and I’m trying to use the Regex to extract this double that changes every time (I need to compare some numbers), but I’ll also try the find relative one more time (I’ve tried but didn’t work I think).
      Anyways great write up, your efforts are much appreciated.

      Thanks a heaps,
      Anitha

      Delete
  2. Enter a Number :4
    The Fibonacci sequence for the number 4 is :
    fib.sh: 27: fib.sh: Syntax error: Bad for loop variable

    Copy/paste from here, no errors.

    ReplyDelete
    Replies
    1. Hi Venu,

      Thank you for making your blogs an embodiment of perfection and simplicity. You make everything so easy to follow.


      I have just upgraded my Microsoft office to office 365.
      I have a workflow that works perfectly fine previously, however after the upgrade, it always gets “stuck” before performing an Excel Application Scope activity.
      For example, I programmed it to open the excel sheet called “FullList.xlsm” using excel application scope Uipath Training USA .When debuging, i realise it stops at this execution and hangs.
      When i tried to manually open the excel sheet, it tells me it is locked for editing, which i assume is due to UiPath Studio.
      Any ideas how do i resolve this?

      Great effort, I wish I saw it earlier. Would have saved my day :)

      Thanks,
      Kevin

      Delete
    2. Hi Kleia Paluca,

      Gratitude for putting up this prolific article! You truly make everything a cake walk. Genuinely good stuff, saving time and energy.I started using UiPath Tutorial

      blog for my training practice.

      On which topic you are looking for in HRMS? There are lots of topics in HRMS Like Payroll, Employee creation or updation, element entries absence so on. There are lots of documents under Documents Section in our Club- Site itself. You can browse the documents under HRMS Section in Documents Area.

      Very useful article, if I run into challenges along the way, I will share them here.

      Regards,
      Morgan

      Delete
  3. Shame on you!

    a=1;b=1;for i in `seq 91`;do echo $((x=b,b=a+b,a=x));done

    That's all, folks!

    ReplyDelete
  4. Same thing, if you want to print also first numbers of sequence:

    echo $((b=1,a=0));for i in `seq 92`;do echo $((x=b,b=a+b,a=x));done

    ReplyDelete
  5. Prints out Fibonacci numbers

    #include

    int main()
    {
    int old_number= 1;
    int current_number = 1;
    int next_number;

    while (current_number < 200) {

    printf("%d\n", current_number);
    next_number = current_number + old_number;

    old_number = current_number;
    current_number = next_number;
    }
    return (0);
    }

    ReplyDelete
    Replies
    1. Hey Brother,
      Thanks for the timely post, at least for me. I have encore time wondered about the transition, but somehow did not dare, because the information I came across very controversial.
      But today, after reading your article I’m very confident to take up any challenges.

      https://asha24.com/blog/blue-prism-vs-automation-anywhere-vs-uipath
      Appreciate your effort for making such useful blogs and helping the community.
      Thank you,
      Ganesh

      Delete
  6. To include commas in the output:

    echo -n "$f1 " | sed -r ':L;s=\b([0-9]+)([0-9]{3})\b=\1,\2=g;t L'

    ReplyDelete
  7. Thanks for your article. Your post helped me to understand the future of QTP automation testing tool. Keep on your blog with awesome information. Best QTP Course in Chennai | QTP training

    ReplyDelete
  8. The future of software testing is on positive note. It offers huge career prospects for talented professionals to be skilled software testers.
    Regards,
    Software testing training in chennai|testing training chennai|Software testing institutes in chennai

    ReplyDelete
  9. Individual is expected to choose properly the right Selenium software regarding his/her desires.
    Selenium IDE is allocated as a Firefox plug in. It's better to install and use. Consumer isn't needed to get previous programming information. Selenium IDE can be an ideal tool for a unknowing person.
    Selenium RC is actually a host which allows user to generate test programs in a preferred programming language. It also enables undertaking test programs within the huge spectrum of browsers . For more info on this check this link

    ReplyDelete
  10. The tool was later on commended together with the brand “Selenium Core”.

    Selenium IDE (Selenium Integral Development Environment)

    Selenium IDE was created by Shinya Kasatani. Although studying Selenium Central, he understood that this JavaScript signal may be lengthy to generate an integrated development environment (IDE) which can be plugged into Mozilla Firefox . For more info on this see this link

    ReplyDelete
  11. Nice blog, here I had an opportunity to learn something new in my field. I have an expectation about your future post so please keep updates.
    Selenium training institute in Chennai|Selenium Training Chennai

    ReplyDelete
  12. Hi there colleagues, its fantastic article regarding educationand completely defined,
    keep it up all the time.

    ReplyDelete
  13. I really appreciate information shared above. It’s of great help. If someone want to learn Online (Virtual) instructor lead live training in Data Science with Python , kindly contact us http://www.maxmunus.com/contact
    MaxMunus Offer World Class Virtual Instructor led training on TECHNOLOGY. We have industry expert trainer. We provide Training Material and Software Support. MaxMunus has successfully conducted 100000+ trainings in India, USA, UK, Australlia, Switzerland, Qatar, Saudi Arabia, Bangladesh, Bahrain and UAE etc.
    For Demo Contact us.
    Sangita Mohanty
    MaxMunus
    E-mail: sangita@maxmunus.com
    Skype id: training_maxmunus
    Ph:(0) 9738075708 / 080 - 41103383
    http://www.maxmunus.com/

    ReplyDelete
  14. Bash GURU, mn e lud manqka

    ReplyDelete

  15. Testing an application is become essential for any product to get an effective result. Your post help you to gain more info on Selenium Testing

    Selenium Training in Anna Nagar |
    Selenium Training in T Nagar

    ReplyDelete
  16. I am reading your post from the beginning, it was so interesting to read & I feel thanks to you for posting such a good blog, keep updates regularly.

    selenium training in bangalore|

    ReplyDelete
  17. This comment has been removed by the author.

    ReplyDelete
  18. Needed to compose you a very little word to thank you yet again regarding the nice suggestions you’ve contributed here.

    Java Training In Bangalore

    ReplyDelete
  19. Interesting post! This is really helpful for me. I like it! Thanks for sharing!
    MBA Project Center in Chennai | MBA Project Center in Velachery

    ReplyDelete
  20. It has been simply incredibly generous with you to provide openly what exactly many individuals would’ve marketed for an eBook to end up making some cash for their end, primarily given that you could have tried it in the event you wanted.

    Selenium Training in Bangalore

    ReplyDelete
  21. Salemetsiz Be,


    Gasping at your brilliance! Thanks a tonne for sharing all that content. Can’t stop reading. Honestly!


    I think choosing one over the other as a general response is not useful.
    Automating is really time consuming when starting and until it creates momentum Manual testing adds more value to a team. Also when automating we are testing for expected things, intuition and flexibility of manual ad-hoc testing can't be programmed.
    But as your test cases start to pile up, and regressions become harder to do, there automation is king.
    Very useful post !everyone should learn and use it during their learning path.

    Thank you,

    ReplyDelete
  22. I feel really happy to have seen your webpage and look forward to so many more entertaining times reading here. Thanks once more for all the details.


    rpa Training in Bangalore


    ReplyDelete
  23. It's nice that you share such information with us, I am grateful to you.

    ReplyDelete
  24. Hello There,

    Gasping at your brilliance! Thanks a tonne for sharing all that content. Can’t stop reading. Honestly! Uipath Training USA

    Is it Fixed now ?
    I am getting below error while using Microsoft OCR for PDF
    Main has thrown an exception
    Message: Error performing OCR: MicrosoftErrorCreateEngine
    Source: Microsoft OCR
    Exception Type: Exception
    System.Exception: Error performing OCR: MicrosoftErrorCreateEngine
    Server stack trace:
    at UiPath.Vision.OCR.OCRClient.ScrapeUsingHostService(OCRInput input, OCROptions options, CancellationToken cancelToken)
    at UiPath.Vision.OCR.OCRClient.Scrape(OCRInput input, OCROptions options, CancellationToken cancelToken, Boolean useHostProcess)
    at UiPath.Vision.UiImage.ScrapeOCR(OCROptions options, CancellationToken cancellationToken)
    at UiPath.Core.Activities.OCREngineActivity.<>c__DisplayClass36_0.b__0()
    at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
    at System.Runtime.Remoting.Messaging.StackBuilderSink.AsyncProcessMessage(IMessage msg, IMessageSink replySink)
    Exception rethrown at [0]:
    at System.Runtime.Remoting.Proxies.RealProxy.EndInvokeHelper(Message reqMsg, Boolean bProxyCase)
    at System.Runtime.Remoting.Proxies.RemotingProxy.Invoke(Object NotUsed, MessageData& msgData)
    at System.Func1.EndInvoke(IAsyncResult result) at UiPath.Core.Activities.OCREngineActivity.EndExecute(AsyncCodeActivityContext context, IAsyncResult result) at System.Activities.AsyncCodeActivity1.System.Activities.IAsyncCodeActivity.FinishExecution(AsyncCodeActivityContext context, IAsyncResult result)
    at System.Activities.AsyncCodeActivity.CompleteAsyncCodeActivityData.CompleteAsyncCodeActivityWorkItem.Execute(ActivityExecutor executor, BookmarkManager bookmarkManager)
    Follow my new blog if you interested in just tag along me in any social media platforms!


    MuchasGracias,
    Radhey

    ReplyDelete
  25. 15. Hello Mate,


    Gratitude for putting up this prolific article! You truly make everything a cake walk. Genuinely good stuff, saving time and energy.

    Dim WSHShell
    Set WSHShell = CreateObject("WScript.Shell")
    WSHShell.Run "C:\MentorGraphics\EEVX.2\SDD_HOME\common\win64\bin\viewdraw.exe -Embedding"
    Dim DxdApp 'As ViewDraw.Application
    Set DxdApp = CreateObject("ViewDraw.application")
    DxdApp.Visible = True
    DxdApp.LaunchSymbolEditor "gate_ary:gate_ary_fpga_1498_pfr.1"

    An Information Message Prompt: Mutiple symbols detected. Do you want to merge these into a single compound view? (Seems like it is trying to open the central library. But, there is only *.1 for the symbol gate_ary_fpga_1498_pfr, no mutiple symbols found!)

    In the output window:
    Started C:\MentorGraphics\EEVX.2\SDD_HOME\common\win64\bin\nse.exe -parent dx -icdb "" -snapshot "" "gate_ary:gate_ary_fpga_1498_pfr.1"
    Finished C:\MentorGraphics\EEVX.2\SDD_HOME\common\win64\bin\nse.exe
    Super likes !!! for this amazing post. I thinks everyone should bookmark this.


    Thank you,

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

    ReplyDelete
  27. Howdy Mate,


    Great info! I recently came across your blog and have been reading along.
    I thought I would leave my first comment. I don’t know what to say except that I have

    One of the current trending Automation technology in India. Probably in 2more years this will get more trending.
    have courses on RPA. Am planning to buy asap. Don't waste money on trainings. Check prices in website. Every month that give courses at best prices.
    Better to buy from there and start. I have learnt 3 courses from . Very good course materials available. Check it
    It was cool to see your article pop up in my google search for the process yesterday. Great Guide. UiPath Tutorial

    Keep up the good work!


    Gracias
    Ajeeth

    ReplyDelete
  28. When you apply for a vocation as a peruser, you will be given an example content and requested to dissect it, utilizing the organization's scope layout, in a set timeframe, FOR FREE. script reader

    ReplyDelete
  29. 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. Payday Loans near me Chicago

    ReplyDelete
  30. This article is very much helpful and i hope this will be an useful information for the needed one.Keep on updating these kinds of informative things...

    Embedded System training in Chennai | Embedded system training institute in chennai | PLC Training institute in chennai | IEEE final year projects in chennai | VLSI training institute in chennai

    ReplyDelete