'Cannot run Gnat Studio

I'm trying to run Gnat Studio on Ubuntu 22.04 but I get the following error:

/opt/gnatstudio/bin/gnatstudio_exe: error while loading shared libraries: libtinfo.so.5: cannot open shared object file: No such file or directory

I have installed it via the following steps:

  • Downloaded the "x86 GNU Linux (64 bits)" community edition and ran this
  • Ran /opt/GNAT/2021/doinstall
  • Ran /opt/gnatstudio/bin/gnatstudio and got the above error (sudo-running this yields the same error)

I'm wondering if this is down to 22.04 being a very recent release and some shared libraries are missing from the installation bundle?

Any pointers would be much appreciated.

Thanks



Solution 1:[1]

allNonNegative = True
summ = 0
while allNonNegative:
    a = int(input("enter a number: "))
    if a >= 0:
        summ = summ + a
    else:
        allNonNegative= False
        print(summ)

Solution 2:[2]

You need use IF statements to check negative values

summ = 0
while True:
    a = int(input("enter a number: "))
    if a < 0:
        break
    summ = summ + a
    print(summ)

Solution 3:[3]

You don't need an if at all. The condition is already checked by the while. No need to check it again inside the body.

Here are two alternatives to fix your issue.

First alternative: cancel the extra addition by a subtraction

a = 0
summ = 0
while a >= 0:
    a = int(input("enter a number: "))
    summ = summ + a
summ = summ - a
print(summ)

Second alternative: only add nonnegative numbers

prompt = "enter a number: "
summ = 0
a = int(input(prompt))
while a >= 0:
    summ = summ + a
    a = int(input(prompt))
print(summ)

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1
Solution 2 Sergey K
Solution 3 Stef