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

Possibly Related Threads…
Thread Author Replies Views Last Post
Question Experimenting with a "StringList" type for simpler handling of string arrays/lists Heimdall 18 1,263 12-19-2025, 12:51 PM
Last Post: Heimdall
  Sub not Reconizing Dim as String pmackay 18 1,477 10-16-2025, 03:32 PM
Last Post: pmackay
  for performance, what's the best variable type to use for boolean _TRUE & _FALSE ? madscijr 12 1,263 09-29-2025, 02:59 PM
Last Post: dakra137
  Illegal string-number conversion Herve 7 775 07-07-2025, 09:53 AM
Last Post: a740g
  need help printing a scaled string in a custom font to a 32-bit image madscijr 9 1,168 07-03-2025, 04:48 PM
Last Post: SMcNeill

Forum Jump:


Users browsing this thread: 1 Guest(s)