The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
[HP50g] why this ?
11-12-2017, 09:19 PM (This post was last modified: 11-12-2017 09:34 PM by Gilles59.)
Post: #1
[HP50g] why this ?
I know it's not a good idea to change the value of the counter of a "FOR NEXT" loop. But consider :

Code:

«  0.
   0. 100. FOR p
    1. 'p' STO+
    1. +
   NEXT
»

You get 50. seems logic...

Now try :

Code:
«  0.
   1. 100. FOR p
    p NEXTPRIME 'p' STO
    1. +
   NEXT
»

You get .... 1. The loop excecutes only once.
Is this a bug or I misunderstand something ?

EDIT : Ohoh ! The bug is only in approx mode ( |R ) .... NEXTPRIME always returns an integer ( 1. NEXTPRIME returns 2 and the loop dont works). With and I->R after NEXTPRIME, it's OK
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
[HP50g] why this ? - Gilles59 - 11-12-2017 09:19 PM
RE: [HP50g] why this ? - Gerson W. Barbosa - 11-12-2017, 11:16 PM



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