Post Reply 
Problem with a list in CAS-program
10-29-2017, 06:54 PM
Post: #16
RE: Problem with a list in CAS-program
As Rudi does not know what the by him mentioned program does I add this working code with german comments:
Es berechnet die Anzahl aller Teiler von n!
Code:
 #cas
POSDIVNF(n):=
BEGIN
LOCAL l,p,j,m;
p:=1;
l:= MAKELIST(1,X,1,n);//maximal kann n der größte Primfaktor von n! sein, Liste von 1en machen
 FOR j FROM 2 TO n DO  //bei 2 anfangen die Faktoren von n! zu untersuchen
  p:=1;
m:=j;
   WHILE p≤j DO  //höchstens bis zum aktuellen Faktor können Primzahlen auftreten
     p:=nextprime(p);
      WHILE irem(m,p)==0 DO //solange p m teilt
      m:=iquo(m,p); //wird dividiert
       l[p]:=l[p]+1; //und 1 zur aktuellen Position in der Liste addiert
      END;
   END;
 END;
  return ΠLIST(l);// die Gesamtzahl positiver Faktoren von n! zurückliefern
END;
#end
Arno
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Problem with a list in CAS-program - Rudi - 10-29-2017, 04:55 PM
RE: Problem with a list in CAS-program - Arno K - 10-29-2017 06:54 PM



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