MACRO MENENTUKAN FAKTORIAL
FAK F
MCONSTANT N i FAK
MCOLUMN F
#MENGHITUNG FAKTORIAL
LET N=F
LET FAK=1 do i=1:n
LET FAK=i*FAK
enddo
PRINT FAK
ENDMACRO
MACRO MENENTUKAN RATA-RATA
rata(x)
mconstant sigma n i rata
mcolumn x
let n=count(x)
let sigma=0 do i=1:n
let sigma=sigma + x(i)
enddo
let rata=sigma/n
print rata
endmacro
MAKRO MENGHITUNG KOMBINASI
MACRO COMB P Q
MCONSTANT N i FAK R j FAK1 B K FAK2 COMB
MCOLUMN Q P
#MENGHITUNG FAKTORIAL N
LET N=Q
LET FAK=1
DO i=1:N
LET FAK=i*FAK ENDDO
# MENGHITUNG FAK R
LET R=P
LET FAK1=1
DO j=1:R
LET FAK1=j*FAK1
ENDDO
# MENGHITUNG FAK N-R
LET B=N-R
LET FAK2=1
DO K=1:B
LET FAK2=K*FAK2
ENDDO
LET COMB = FAK/((FAK1)*(FAK2))
PRINT COMB
ENDMACRO
MACRO MENGITUNG PERMUTASI
MACRO
PERM P Q
MCONSTANT N i FAK B j FAK1 PER R
MCOLUMN Q P
#MENGHITUNG FAKTORIAL N
LET N=Q
LET FAK=1
DO i=1:N
LET FAK=i*FAK
ENDDO
# MENGHITUNG FAK=P-Q
LET R=P
LET B=N-R
LET FAK1=1
DO j=1:B
LET FAK1=j*FAK1
ENDDO
LET PER=FAK/FAK1
PRINT PER
ENDMACRO
MACRO MENENTUKAN MEDIAN
macro
input x
mconstant b n i a p y median j k l modulo
mcolumn x
#mengurutkan data
let n=count (x)
do i=1:n
do j=1:n
if j>i and x(i) > x(j)
let a=x(i)
let x(i)=x(j)
let x (j)=a
endif
enddo
enddo
#mengitung median
let modulo = mod (n,2)
if modulo=1
let p=n+1
do k=1:n
let k=p/2
let median=x(k)
enddo
else
let l=n/2
let k=l+1
let median=(x(l)+x(k))/2
endif
print x
print median
endmacro
PERM P Q
MCONSTANT N i FAK B j FAK1 PER R
MCOLUMN Q P
#MENGHITUNG FAKTORIAL N
LET N=Q
LET FAK=1
DO i=1:N
LET FAK=i*FAK
ENDDO
# MENGHITUNG FAK=P-Q
LET R=P
LET B=N-R
LET FAK1=1
DO j=1:B
LET FAK1=j*FAK1
ENDDO
LET PER=FAK/FAK1
PRINT PER
ENDMACRO
MACRO MENENTUKAN MEDIAN
input x
mconstant b n i a p y median j k l modulo
mcolumn x
#mengurutkan data
let n=count (x)
do i=1:n
do j=1:n
if j>i and x(i) > x(j)
let a=x(i)
let x(i)=x(j)
let x (j)=a
endif
enddo
enddo
#mengitung median
let modulo = mod (n,2)
if modulo=1
let p=n+1
do k=1:n
let k=p/2
let median=x(k)
enddo
else
let l=n/2
let k=l+1
let median=(x(l)+x(k))/2
endif
print x
print median
endmacro
MACRO MENENTUKAN MODUS
macro
input x
mconstant n i j k modus max
mcolumn x y
let n = count (x)
do i= 1:n
let y(i) =1
do k=1:n
if k>i and x(i)=x(k)
let y(i)=y(i)+1
endif
enddo
enddo
print y(x(i))
let max=y(1)
let modus =x(1)
do j=2:n
if y(j)>max
let max=y(j)
let modus= x(j)
endif
enddo
do k=1:n
if y(k)=max
let modus= x(k)
print modus
endif
enddo
endmacro
input x
mconstant n i j k modus max
mcolumn x y
let n = count (x)
do i= 1:n
let y(i) =1
do k=1:n
if k>i and x(i)=x(k)
let y(i)=y(i)+1
endif
enddo
enddo
print y(x(i))
let max=y(1)
let modus =x(1)
do j=2:n
if y(j)>max
let max=y(j)
let modus= x(j)
endif
enddo
do k=1:n
if y(k)=max
let modus= x(k)
print modus
endif
enddo
endmacro
MACRO UNTUK MENGITUNG VARIANSI
macro
variansi x
mconstant i jumlah rata b z n var
mcolumn x y
let n=count (x)
let jumlah=0
do i=1:n
let jumlah=x(i)+jumlah
enddo
let rata=jumlah/n
do i=1:n
let y(i)=(x(i)-rata)**2
enddo
let z=0
do i=1:n
let z=y(i)+z
enddo
let b =n-1
let var=z/b
print var
endmacro
macro
variansi x
mconstant i jumlah rata b z n var
mcolumn x y
let n=count (x)
let jumlah=0
do i=1:n
let jumlah=x(i)+jumlah
enddo
let rata=jumlah/n
do i=1:n
let y(i)=(x(i)-rata)**2
enddo
let z=0
do i=1:n
let z=y(i)+z
enddo
let b =n-1
let var=z/b
print var
endmacro