Fwd: How to calculate/process this one?
Fwd: How to calculate/process this one?
- Subject: Fwd: How to calculate/process this one?
- From: Michelle Steiner <email@hidden>
- Date: Sat, 27 Apr 2002 16:49:25 -0700
Begin forwarded message:
From: Michelle Steiner <email@hidden>
Date: Sat Apr 27, 2002 08:48:08 AM America/Phoenix
To: Martin Michel <email@hidden>
Subject: Re: How to calculate/process this one?
On Saturday, April 27, 2002, at 05:10 AM, Martin Michel wrote:
Let's say I have a random number like 11050. Now I want to add each
pair of consecutive digits to give the next line (so 11050 becomes
2155). I want to repeat this step until I have a two-digit number.
Manually, to get the check answer:
11050
2155
3610
971
168
714
85
The script:
set the numstring to "11050"
set the finalAnwer to my calculate(numstring) as number
to calculate(invalue)
set stringcount to count (invalue)
if stringcount is 2 then
return invalue
else
set the tempstring to ""
repeat with loop from 1 to stringcount - 1
set the sum to (character loop of invalue) + (character
(loop + 1) of invalue)
set tempstring to tempstring & sum
end repeat
calculate(tempstring)
end if
end calculate
-- 85
We're not human beings having a spiritual experience.
We're spiritual beings having a human experience.
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.