是否有一个特殊的排列公式 [英] Is there a special formula for permutation

查看:94
本文介绍了是否有一个特殊的排列公式的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

谁可以帮助我使用QBASIC代码来查找给定数字的排列. 我真的很感激. 我尝试编写一些代码,但未给出所需的答案.

Who can help me out with a QBASIC CODE to find the permutation of a given number. I'd really appreciate. I've tried writing some codes but it's not giving the required answer.

推荐答案

如果通过排列,您的意思是阶乘,那么以下是您需要的代码. 它会得到一个整数并计算其阶乘.

If by permutation you mean the factorial then the following is the code that you need. It will get an integer and compute its factorial.

DECLARE FUNCTION Factorial (n)
FUNCTION Factorial (n)
  IF n = 0 THEN
    Factorial = 1
  ELSE
    Factorial = n * Factorial(n - 1)
  END IF
END FUNCTION
INPUT "PLEASE ENTER AN INTEGER", n
PRINT n;"! = "; Factorial(n)

但是,如果说置换是指序列1,...,n的所有置换,那么这又是另一回事了.因此,请在评论中让我知道.

But if by permutation you mean all of the permutations of the sequence 1,...,n then it is another story. So let me know in the comments.

这篇关于是否有一个特殊的排列公式的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆