Post Reply 
[VA] Short & Sweet Math Challenges #23: "May the 4th Be With You !" Special
05-10-2018, 08:23 AM (This post was last modified: 05-10-2018 08:28 AM by J-F Garnier.)
Post: #8
RE: [VA] Short & Sweet Math Challenges #23: "May the 4th Be With You !" ...
(05-09-2018 10:53 PM)Valentin Albillo Wrote:  
J-F Garnier Wrote:It is very difficult (or impossible) to make a loop from the keyboard command line and include tests in it.

It's difficult but not impossible, it can be done as long as it all fits in a 96-char line. ...

Thanks for your comments, Valentin. What I meant is that it is not possible to include a IF THEN structure in a FOR NEXT loop, because NEXT is not allowed after THEN or ELSE.
So we have to find other ways to take decisions as I did in my solution and as you illustrated with your interesting examples.

For the OPTION BASE issue, here is an updated solution (I don't like changing global settings like OPTION BASE):
>DESTROY ALL @ A(1)=-1 @ A(2)=49
>FOR J=1 TO 46 @ X=(A(1)+A(2))/2 @ S=0 @ FOR I=1 TO 100 @ S=S+SQR(X+I)-7 @ NEXT I @ A(1+(S>0))=X @ NEXT J
>X
3.28838856026


Waiting for your own solution(s) !

J-F
Visit this user's website Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: [VA] Short & Sweet Math Challenges #23: "May the 4th Be With You !" ... - J-F Garnier - 05-10-2018 08:23 AM



User(s) browsing this thread: 1 Guest(s)