Post Reply 
Running program from Home or Program menu
11-25-2019, 11:24 AM
Post: #3
RE: Running program from Home or Program menu
This other one is very strange also (still a problem with isprime):

Goal: find Prime numbers starting with 82 and ending with 1. It takes a starting point as argument to avoid counting from 821, but also from 82[any number]1.

Related to: This tweet from Fermat’s library

Expected: halt for each prime number found
Result (home): OK it halts each time a prime number is found
Result (Run softkey): KO it never halts!

Code:

EXPORT Prime821;

EXPORT PRIME82(N)
BEGIN
 Prime821:=IP(N);
 LOCAL A:=ALOG(IP(LOG(Prime821+1)+2)), C;
 LOCAL D:=A/10;
 REPEAT
  Prime821:=Prime821+1;
  IF Prime821≥D THEN
   A:=A*10;
   D:=D*10;
  END;
  C:=82*A+Prime821*10+1;
  PRINT(C);
 UNTIL CAS.isprime(C); // OR ISKEYDOWN();
 MSGBOX("isprime " + C + "? "+ CAS.isprime(C));
 RETURN C; 
END;

Platform used: HP Prime beta iOS (version 11-20-219)
I should test on my physical calc (I have a G1), did not have the time yet.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Running program from Home or Program menu - pinkman - 11-25-2019 11:24 AM



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