gpt4 book ai didi

wolfram-mathematica - FactorInteger 的替代形式? (数学)

转载 作者:行者123 更新时间:2023-12-04 08:05:30 25 4
gpt4 key购买 nike

在 Mathematica 中

a = FactorInteger[44420069694]

分配
{{2, 1}, {3, 1}, {7, 1}, {11, 2}, {13, 1}, {23, 2}, {31, 1}, {41, 1}}

到一个。现在,我希望扩展这些列表中的每一个,而不是带有指数的因子。上面的因式分解将变成
{2, 3, 7, 11, 11, 13, 23, 23, 31, 41}

我写了以下函数:
b = {}; Do[Do[b = Append[b, a[[i]][[1]]], {a[[i]][[2]]}], {i, Length[a]}]

但如果你问我,它看起来很丑。肯定必须有一种更简洁的方法来实现这一目标?

最佳答案

是的,例如:

Flatten[Map[Table[#[[1]], {#[[2]]}] &, a]]

关于wolfram-mathematica - FactorInteger 的替代形式? (数学),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/763915/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com