Thread Rating:
  • 2 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to reorder string variable x factorial different ways?
#2
(04-24-2024, 11:14 AM)Circlotron Wrote: Say I have a string variable abcd$. The letters in the variable can be arranged 4 factorial or 4x3x2x1 different ways. How can I produce every combination? Find Len(abcd$) then a for/next loop Len factorial times, but what inside the loop? I'm at a loss here. Huh
This is the calculation of the factorial: n!

Code: (Select All)

'Fakultaet iterativ mit FOR-Schleife - 11. Feb. 2023

$Console:Only
Option _Explicit

Declare Function Fakultaet(n As Integer) As _Integer64

Dim As Integer n

Locate 2, 3
Print "Iterative Berechnung der Fakultaet - (n!)"

Locate 4, 3
Input "Fakultaet von (n): ", n

Locate 5, 3
Print Using "Die Fakultaet von ### ist: ###,###,###"; n, Fakultaet(n)

End 'Hauptprogramm


Function Fakultaet (n As Integer)

  Dim As _Integer64 fakul
  Dim As Integer i

  fakul = 1
  For i = 1 To n
    fakul = fakul * i
  Next

  Fakultaet = fakul

Oder in Julia:

[Image: Julia-Fakultaet.jpg]
Reply


Messages In This Thread
RE: How to reorder string variable x factorial different ways? - by Kernelpanic - 04-24-2024, 11:32 AM



Users browsing this thread: 1 Guest(s)