idivis inWP34s
11-28-2015, 11:25 AM
Post: #11
 Thomas Klemm Senior Member Posts: 1,542 Joined: Dec 2013
RE: idivis inWP34s
(11-28-2015 07:28 AM)ggauny@live.fr Wrote:  No I have not see where you are cheated.

The comparison in the while-loop should be i < n instead of i <= n:
Code:
def idivis(n):     i = 0     while i < n:         i += 1         if n % i == 0:             print i

Otherwise the last test will be with i = n+1 instead of i = n. But I was lazy when I noticed my mistake and just moved the INC command in front of the comparison:
Code:
LBL 00 RCL 01 ; i RCL 00 ; n X<Y? GTO 01 RCL 01 ; i 1 + STO 01 ; i

Code:
LBL 00 RCL 00 ; n INC 01 ; i X<? 01 ; i RTN

But in the end it doesn't matter much since n+1 is not a divider of n.

Cheers
Thomas
 « Next Oldest | Next Newest »

 Messages In This Thread idivis inWP34s - ggauny@live.fr - 11-27-2015, 07:26 PM RE: idivis inWP34s - Dieter - 11-27-2015, 08:24 PM RE: idivis in WP 34S - walter b - 11-27-2015, 08:34 PM RE: idivis inWP34s - Dieter - 11-27-2015, 08:53 PM RE: idivis inWP34s - walter b - 11-27-2015, 10:27 PM RE: idivis inWP34s - Dieter - 11-27-2015, 11:12 PM RE: idivis inWP34s - Marcus von Cube - 11-28-2015, 11:14 AM RE: idivis inWP34s - walter b - 11-28-2015, 12:01 PM RE: idivis inWP34s - Thomas Klemm - 11-28-2015, 12:14 AM RE: idivis inWP34s - ggauny@live.fr - 11-28-2015, 06:30 AM RE: idivis inWP34s - Dieter - 11-28-2015, 07:35 PM RE: idivis inWP34s - ggauny@live.fr - 11-28-2015, 07:28 AM RE: idivis inWP34s - Thomas Klemm - 11-28-2015 11:25 AM RE: idivis inWP34s - Didier Lachieze - 11-29-2015, 12:25 PM RE: idivis inWP34s - ggauny@live.fr - 03-27-2016, 09:34 AM RE: idivis inWP34s - ggauny@live.fr - 11-29-2015, 12:34 PM RE: idivis inWP34s - ggauny@live.fr - 11-29-2015, 12:47 PM RE: idivis inWP34s - Paul Dale - 03-27-2016, 10:26 AM RE: idivis inWP34s - ggauny@live.fr - 03-27-2016, 10:43 AM RE: idivis inWP34s - Didier Lachieze - 03-27-2016, 11:17 AM RE: idivis inWP34s - Paul Dale - 03-27-2016, 11:14 AM RE: idivis inWP34s - ggauny@live.fr - 03-27-2016, 12:00 PM

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