| View previous topic :: View next topic |
| Author |
Message |
vtol Valued Contributor


Joined: 05 Feb 2004 Posts: 656 Location: Eastern Indiana
|
Posted: Sun Feb 26, 2006 7:25 am Post subject: Is there a better way to READ if ODD or EVEN numbers exists? |
|
|
Is there a better way to READ if ODD or EVEN numbers exists?
Heres how I do it, but there must be a less complex way out there.
I just thought if someone else has this worked out allready it would save me time re-inventing the ODD EVEN wheel
| Code: | %%counter = 0
REPEAT
%%counter = @succ(%%counter)
%%divide = @format(@fdiv(%%counter,2),100.1)
%%total = @fmul(%%divide,2),%%multiply)
%%multiply = @fmul(%%divide,2)
%%check_fraction = @SUBSTR(%%divide,3,3)
IF @EQUAL(%%check_fraction,0)
INFO EVEN whole number if the fraction part of the counter number is zero %%total"."%%check_fraction
END
UNTIL @equal(%%counter,7) |
Thanks in advance... |
|
| Back to top |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Sun Feb 26, 2006 8:45 am Post subject: |
|
|
there is an easier way ... i knew that my years at uni would one day pay off
| Code: | %i = 0
repeat
if @zero(@mod(%i,2))
warn %i is even
else
warn %i is odd
end
%i = @succ(%i)
until @equal(%i,10) |
serge _________________
|
|
| Back to top |
|
 |
vtol Valued Contributor


Joined: 05 Feb 2004 Posts: 656 Location: Eastern Indiana
|
Posted: Fri Mar 03, 2006 10:58 am Post subject: |
|
|
yes,
that helped me tremendously even works on multiplication.
I should have noticeed that function, but its been too long since my algebra and geometry old skool days.
Thanks a @FABS(1,000,000,000.321) ( I didnt notice that either)
Good thing we have you here
Hey I been trying to get a math formula that I can write on paper and take up on a roof for example, in case you dont have a calc handy say.
Heres all I have, but as you can see it requires a calc for the SQ ROOT.
I bet you know another formula that could get the diagonal by using the known sides a and b without requiring a calc. ( I lost the formula I had)
Pythagorean Theorem (I know the a and b - just want the diagonal)
Oh, and it would need to be for rectangles only (not a square).
a^2+b^2=c^2
lets try EXAMPLE: 4 x 3 = c^2
SQ root is a lot of Newtonizing estimating type divisional formula...
Thanks again I mean Serge... |
|
| Back to top |
|
 |
Serge Professional Member


Joined: 04 Mar 2002 Posts: 1480 Location: Australia
|
Posted: Sat Mar 04, 2006 1:36 am Post subject: |
|
|
you are welcome ... this was an easy question for me
i am not sure what you are asking ... are you after a formula to find the diagonal using pythagoras but without having to use a calculator because of the square root?
if so, i am not aware of any other formula except for an approximation formula that you can use for squares ... the formula has many terms and depending on the accuracy you want, you may only need to use the first 2 terms of the formula, it is a series actually ... i don't remember it off hand but i may be able to look it up if you need it
serge _________________
|
|
| Back to top |
|
 |
vtol Valued Contributor


Joined: 05 Feb 2004 Posts: 656 Location: Eastern Indiana
|
Posted: Tue Mar 07, 2006 9:03 am Post subject: |
|
|
Yeah, that was what I meant, and I allready looked it up before this post, so thanks for confirming what I was thinking, I found that I used to used a fixed number in the place of the PWR number, so I guess i was just spitten words to see where they would splatter
but thanks again, problem solved... twas a fun mathmatical interaction  |
|
| Back to top |
|
 |
|