Shell program to check whether a given number is avogadro number or not.

Hey there,

Did you want to do some calculation against the constant or just determine if a number is avogadro's number or not? If so, all you have to do is test whether or not the number equals the number (6.022 x 10 to the 23rd power).

I'm probably missing something. If you could explain further, maybe I can help.

Best wishes,

Mike

Just determine.

That's all.

Hey There,

Here's one way to do it:

#!/bin/bash

echo -n "Enter your number: "
read answer

if [ "$answer" == "6022000000000000000000000" ]
then
echo "You picked the Avogadro Number! $answer"
else
echo "That number isn't the Avogadro Number!"
fi

Output:

$ ./av.sh
Enter your number: 3120280138
That number isn't the Avogadro Number!

$ ./av.sh
Enter your number: 6022000000000000000000000
You picked the Avogadro Number! 6022000000000000000000000

Hope that helps :)

, Mike

Thanks

No problem. Glad to help :)

, Mike

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.