DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   Shell Scripting (http://www.daniweb.com/forums/forum113.html)
-   -   Avogadro Number (http://www.daniweb.com/forums/thread150101.html)

man5237 Oct 9th, 2008 12:05 am
Avogadro Number
 
Shell program to check whether a given number is avogadro number or not.

eggi Oct 9th, 2008 12:57 am
Re: Avogadro Number
 
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

man5237 Oct 9th, 2008 8:05 am
Re: Avogadro Number
 
Just determine.

That's all.

eggi Oct 10th, 2008 1:06 am
Re: Avogadro Number
 
Hey There,

Here's one way to do it:

Quote:

#!/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:

Quote:

$ ./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

man5237 Oct 10th, 2008 11:43 am
Re: Avogadro Number
 
Thanks

eggi Oct 11th, 2008 12:41 am
Re: Avogadro Number
 
No problem. Glad to help :)

, Mike


All times are GMT -4. The time now is 1:47 am.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC