1. Registered User
Join Date
Oct 2006
Posts
6

if anybody can help with this please

write a simple script. is working properly.
Look at the following examples:
Example 1:
[min@alpha min]\$ ./lastname
Enter an integer number:
3
You entered 3

The sum of all the integers from 0 to 3 is 6
The integer 3 that you entered is odd

Example 2:
[min@alpha min]\$ ./lastname
Enter an integer number:
4
You entered 4

The sum of all the integers from 0 to 4 is 10
The integer 4 that you entered is even
Note: Your lastname script must do 3 things:
1) Display which integer the user has entered. For example, if the user enters 3 then lastname script says "You entered 3"
2) If the user enters an integer. For example, 3 then 1+2+3=6, 4 1+2+3+4=10, or 100 1+2+3+...+100=5050.
the script will have to identify if the user input integer is odd or even and display accordingly. For example, if the user enters 3 it should display "The integer 3 that you entered is odd" or if the user enters 4 it should display "The integer 4 that you entered is odd

2. Registered User
Join Date
Aug 2006
Location
The Netherlands
Posts
248
I don't get it, everything you need to know is here http://www.dbforums.com/showthread.php?t=1610157...

3. Registered User
Join Date
Oct 2006
Posts
6

## hey!

i got it to say the number i put, and to figure out the odd and the even, i just need the addition between 0 and the integer i input i just the formula.

4. Registered User
Join Date
May 2005
Location
South Africa
Posts
1,369
Code:
```i=4  # Read from input
oddeven[0]='even'
oddeven[1]='odd'
echo "The integer \$i is \${oddeven[\$((\$i%2))]} and the sum is \$((\$i*(\$i+1)/2))"```
Formula: http://mathworld.wolfram.com/Sum.html
Last edited by pdreyer; 11-15-06 at 02:10.

5. Registered User
Join Date
Jun 2003
Location
West Palm Beach, FL
Posts
2,713
Originally Posted by nyst8fmind
i got it to say the number i put, and to figure out the odd and the even, i just need the addition between 0 and the integer i input i just the formula.

Try this formula:
Code:
`((sum = n * (n + 1) / 2))`

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•