Procedure.l Mod(a.l, b.l) ProcedureReturn a - a / b * b EndProcedure Procedure.s Primfaktoren(Tmp.l, TrennZ.s) If Tmp = 1 : ProcedureReturn "" : EndIf Erg.s = "" c.l = 0 Repeat a.l = 2 OK.l = #False Repeat If Mod(Tmp, a) = 0 If c : Erg = Erg + TrennZ : EndIf Erg = Erg + Str(a) Tmp = Tmp / a OK = #True c + 1 EndIf a + 1 Until OK Until Tmp = 1 ProcedureReturn Erg EndProcedure Procedure.s Teiler(Tmp.l, TrennZ.s) Erg.s = "1" a.l = 2 EndZahl.l = Tmp / 2 While a <= EndZahl If Mod(Tmp, a) = 0 Erg = Erg + TrennZ + Str(a) EndIf a + 1 Wend Erg = Erg + TrennZ + Str(Tmp) ProcedureReturn Erg EndProcedure #Width = 600 #Height = 500 Start.l = #False If OpenWindow(0, 0, 0, #Width, #Height, #PB_Window_Systemmenu | #PB_Window_ScreenCentered, "Primfaktoren und Teiler") If CreateGadgetList(WindowID()) TextGadget(1, 0, 4, 20, 16, "Von") StringGadget(2, 22, 1, 70, 20, "1", #PB_String_Numeric) TextGadget(3, 95, 4, 15, 16, "bis") StringGadget(4, 112, 1, 70, 20, "100", #PB_String_Numeric) ButtonGadget(5, 190, 1, 40, 20, "Start") ButtonGadget(6, 240, 1, 40, 20, "Stop") ButtonGadget(7, 290, 1, 40, 20, "Clear") ListIconGadget(0, 5, 25, #Width - 10, #Height - 30, "Zahl", 50) AddGadgetColumn(0, 1, "Primfaktoren", 200) AddGadgetColumn(0, 2, "Teiler", 336) c.l = 0 Repeat EventID.l = WindowEvent() If Start DisableGadget(6, 0) DisableGadget(5, 1) DisableGadget(2, 1) DisableGadget(4, 1) DisableGadget(7, 1) Else DisableGadget(6, 1) If Val(GetGadgetText(2)) <= Val(GetGadgetText(4)) DisableGadget(5, 0) Else DisableGadget(5, 1) EndIf DisableGadget(2, 0) DisableGadget(4, 0) If CountGadgetItems(0) DisableGadget(7, 0) Else DisableGadget(7, 1) EndIf EndIf If Start a1.s = Primfaktoren(TmpL, ", ") a2.s = Teiler(TmpL, ", ") AddGadgetItem(0, c, Str(TmpL)) SetGadgetItemText(0, c, a1, 1) SetGadgetItemText(0, c, a2, 2) c + 1 TmpL + 1 EndIf If TmpL > TmpLStop : Start = #False : EndIf Select EventID Case #PB_EventGadget Select EventGadgetID() Case 5 Start = #True TmpL.l = Val(GetGadgetText(2)) TmpLStop.l = Val(GetGadgetText(4)) Case 6 Start = #False Case 7 ClearGadgetItemList(0) c = 0 EndSelect EndSelect Until EventID = #PB_EventCloseWindow EndIf EndIf End ; ExecutableFormat=Windows ; Executable=C:\Programme\PureBasic\Programme\Mathe\Primfaktoren und Teiler Pro.exe ; DisableDebugger ; EOF