Post Reply 
STOP in 34s
12-01-2015, 08:58 PM
Post: #6
RE: STOP in 34s
(12-01-2015 08:07 PM)ggauny@live.fr Wrote:  It is because I search a routine that give me the primes factors divisors of an integer, so if my test is false I ask the routine return at LBL'x', in others words :
if the test is true : pause, if false go up to the first line to redo the search, but not go to the first line of program.

This is what I don't understand, because to know what is primes divisors of an integer I divide by 2, after i divise by 2 one again, if not divisible I up to line one and I try with 3, and so on.

This is not a problem concerning the R/S key or the STOP command, it's simply a question of the algorithm. Here is a VERY simple, in no way optimized version of such an algorithm. But is will work. ;-)

Code:
input n
divisor = 2

:start   <---------------+
                         ^
if n mod divisor = 0     |
   print divisor         |
   n = n / divisor       |
   goto start   ---------+
                         ^
divisor = divisor + 1    |
if divisor <= sqrt(n)    |
   goto start  ----------+

print n

Now try to write a 34s program that implements this method.

If if works you can add the first improvement: after the first divisor has been incremented from 2 to 3, increment all following divisors by two so that you get 2 3 5 7 9...

(12-01-2015 08:07 PM)ggauny@live.fr Wrote:  It is difficult because I don't understand your english and you don't understand mine.

I am not sure if you would understand my French – it is really bad. #-)
But I think I would understand the one or other French sentence you write. At least if it's not too complicated. ;-)

Dieter
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
STOP in 34s - ggauny@live.fr - 11-30-2015, 10:38 AM
RE: STOP in 34s - Marcus von Cube - 11-30-2015, 06:56 PM
RE: STOP in 34s - Dieter - 12-01-2015, 07:36 PM
RE: STOP in 34s - ggauny@live.fr - 12-01-2015, 08:07 PM
RE: STOP in 34s - walter b - 12-01-2015, 08:29 PM
RE: STOP in 34s - Dieter - 12-01-2015 08:58 PM
RE: STOP in 34s - ggauny@live.fr - 12-03-2015, 08:28 AM
RE: STOP in 34s - Dieter - 12-03-2015, 09:24 AM
RE: STOP in 34s - ggauny@live.fr - 12-03-2015, 09:05 AM
RE: STOP in 34s - ggauny@live.fr - 12-03-2015, 11:06 AM
RE: STOP in 34s - Paul Dale - 12-03-2015, 11:24 AM
RE: STOP in 34s - ggauny@live.fr - 12-03-2015, 11:56 AM
RE: STOP in 34s - walter b - 12-03-2015, 12:11 PM
RE: STOP in 34s - ggauny@live.fr - 12-03-2015, 12:06 PM
RE: STOP in 34s - ggauny@live.fr - 12-03-2015, 12:25 PM
RE: STOP in 34s - Dieter - 12-03-2015, 03:40 PM
RE: STOP in 34s - ggauny@live.fr - 12-03-2015, 06:36 PM



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