von F3K Total » So, 04.09.2011 01:37
Hallo,
ich hätte da noch eine Makro-Lösung:
Code: Alles auswählen
Sub Teiler_ermitteln
dim ovalue as integer
osheet=thiscomponent.sheets(0)
for i=1 to 1000
zaehler=0
ocell=osheet.getcellbyposition(0,i-1)
ocell.value=i
for k=1 to i
if (i mod k)=0 then zaehler=zaehler+1
next k
oresultcell=osheet.getcellbyposition(1,i-1)
oresultcell.value=zaehler
if Zaehler<=2 then
oresultcell=osheet.getcellbyposition(2,i-1)
oresultcell.string="Primzahl"
endif
next i
msgbox "fertig"
end sub
Gruß R
Hallo,
ich hätte da noch eine Makro-Lösung:
[code]Sub Teiler_ermitteln
dim ovalue as integer
osheet=thiscomponent.sheets(0)
for i=1 to 1000
zaehler=0
ocell=osheet.getcellbyposition(0,i-1)
ocell.value=i
for k=1 to i
if (i mod k)=0 then zaehler=zaehler+1
next k
oresultcell=osheet.getcellbyposition(1,i-1)
oresultcell.value=zaehler
if Zaehler<=2 then
oresultcell=osheet.getcellbyposition(2,i-1)
oresultcell.string="Primzahl"
endif
next i
msgbox "fertig"
end sub[/code] Gruß R