| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 31135 人关注过本帖
标题:各位老师好!求助编辑一个大整数的快速乘除法可调用程序
取消只看楼主 加入收藏
ysr2857
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:34
帖 子:809
专家分:77
注 册:2020-2-10
收藏
得分:0 
由于123=3*41,如果用前面的方法判断的话要先试验n是否能被3或41整除,否则可能输出判断结果错误。
2020-02-11 13:12
ysr2857
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:34
帖 子:809
专家分:77
注 册:2020-2-10
收藏
得分:0 
调整了一下,快了一点,没那么快,1001000000~1002000000之间的孪生素数对,将近一个小时了也还没有出来结果呢。

希望老师指导!咋回事呢?

[此贴子已经被作者于2020-2-11 16:06编辑过]

2020-02-11 16:03
ysr2857
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:34
帖 子:809
专家分:77
注 册:2020-2-10
收藏
得分:0 
算出来结果了,约1个多小时呢。
1001000000与1002000000之间有3056对孪生素数对:
1001000111和 1001000113  孪中1001000112
1001000381和 1001000383  孪中1001000382
1001001059和 1001001061  孪中1001001060
1001001227和 1001001229  孪中1001001228
1001001557和 1001001559  孪中1001001558
1001002151和 1001002153  孪中1001002152
1001002229和 1001002231  孪中1001002230
1001002487和 1001002489  孪中1001002488
1001002589和 1001002591  孪中1001002590
1001003681和 1001003683  孪中1001003682
1001004239和 1001004241  孪中1001004240
1001004287和 1001004289  孪中1001004288
1001004371和 1001004373  孪中1001004372
1001005217和 1001005219  孪中1001005218
1001005349和 1001005351  孪中1001005350
1001005427和 1001005429  孪中1001005428
1001006231和 1001006233  孪中1001006232
1001006261和 1001006263  孪中1001006262
1001007347和 1001007349  孪中1001007348
1001007779和 1001007781  孪中1001007780
1001008037和 1001008039  孪中1001008038
1001008661和 1001008663  孪中1001008662
1001009591和 1001009593  孪中1001009592
1001009741和 1001009743  孪中1001009742
1001010011和 1001010013  孪中1001010012
后面还有好多,超长了不发了。
2020-02-11 16:30
ysr2857
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:34
帖 子:809
专家分:77
注 册:2020-2-10
收藏
得分:0 
不会long型的程序,修改以后我的判断法不能运行了,咋回事呢?
2020-02-11 18:14
ysr2857
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:34
帖 子:809
专家分:77
注 册:2020-2-10
收藏
得分:0 
希望老师给个快速的程序!一天也算不出多少,下面是晚上程序晚上算出来的,祝大家新年新年快乐万事如意:
1011000000与1021000000之间有30808对孪生素数对:
1011000371和 1011000373  孪中1011000372
1011000377和 1011000379  孪中1011000378
1011000479和 1011000481  孪中1011000480
1011001427和 1011001429  孪中1011001428
1011001811和 1011001813  孪中1011001812
1011001877和 1011001879  孪中1011001878
1011001967和 1011001969  孪中1011001968
1011003179和 1011003181  孪中1011003180
1011003269和 1011003271  孪中1011003270
1011003359和 1011003361  孪中1011003360
1011003491和 1011003493  孪中1011003492
1011004037和 1011004039  孪中1011004038
1011004067和 1011004069  孪中1011004068
1011004661和 1011004663  孪中1011004662
1011005909和 1011005911  孪中1011005910
1011006011和 1011006013  孪中1011006012
1011006041和 1011006043  孪中1011006042
1011006341和 1011006343  孪中1011006342
1011007007和 1011007009  孪中1011007008
1011007091和 1011007093  孪中1011007092
1011007241和 1011007243  孪中1011007242
1011007451和 1011007453  孪中1011007452
1011007469和 1011007471  孪中1011007470
1011008057和 1011008059  孪中1011008058
1011008291和 1011008293  孪中1011008292
1011008567和 1011008569  孪中1011008568
1011008597和 1011008599  孪中1011008598
1011008891和 1011008893  孪中1011008892
1011009287和 1011009289  孪中1011009288
1011009299和 1011009301  孪中1011009300
1011009341和 1011009343  孪中1011009342
1011009887和 1011009889  孪中1011009888
1011009947和 1011009949  孪中1011009948
1011010289和 1011010291  孪中1011010290
1011010751和 1011010753  孪中1011010752
1011011459和 1011011461  孪中1011011460
1011013019和 1011013021  孪中1011013020
1011013151和 1011013153  孪中1011013152
1011013187和 1011013189  孪中1011013188
1011013649和 1011013651  孪中1011013650
1011013697和 1011013699  孪中1011013698
1011013811和 1011013813  孪中1011013812
1011015539和 1011015541  孪中1011015540
1011015557和 1011015559  孪中1011015558
1011015911和 1011015913  孪中1011015912
1011016001和 1011016003  孪中1011016002
1011016751和 1011016753  孪中1011016752
1011017087和 1011017089  孪中1011017088
1011017219和 1011017221  孪中1011017220
1011017867和 1011017869  孪中1011017868
1011017879和 1011017881  孪中1011017880
1011018131和 1011018133  孪中1011018132
1011018719和 1011018721  孪中1011018720
1011019421和 1011019423  孪中1011019422
1011019871和 1011019873  孪中1011019872
1011019967和 1011019969  孪中1011019968
1011020027和 1011020029  孪中1011020028
1011020471和 1011020473  孪中1011020472
1011020501和 1011020503  孪中1011020502
1011020537和 1011020539  孪中1011020538
1011021377和 1011021379  孪中1011021378
1011021617和 1011021619  孪中1011021618
1011021701和 1011021703  孪中1011021702
1011022919和 1011022921  孪中1011022920
1011023477和 1011023479  孪中1011023478
1011023567和 1011023569  孪中1011023568
1011023639和 1011023641  孪中1011023640
1011023729和 1011023731  孪中1011023730
1011024851和 1011024853  孪中1011024852
1011025619和 1011025621  孪中1011025620
1011026759和 1011026761  孪中1011026760
1011026789和 1011026791  孪中1011026790
1011026921和 1011026923  孪中1011026922
1011026957和 1011026959  孪中1011026958
1011027497和 1011027499  孪中1011027498
1011028349和 1011028351  孪中1011028350
1011028631和 1011028633  孪中1011028632
1011028721和 1011028723  孪中1011028722
1011028829和 1011028831  孪中1011028830
1011028937和 1011028939  孪中1011028938
1011029687和 1011029689  孪中1011029688
1011029909和 1011029911  孪中1011029910
1011030899和 1011030901  孪中1011030900
1011032327和 1011032329  孪中1011032328
1011033167和 1011033169  孪中1011033168
1011033431和 1011033433  孪中1011033432
1011033449和 1011033451  孪中1011033450
1011033731和 1011033733  孪中1011033732
1011033761和 1011033763  孪中1011033762
1011034259和 1011034261  孪中1011034260
1011034991和 1011034993  孪中1011034992
1011035489和 1011035491  孪中1011035490
后面还多内容超长不发了,程序慢,需要改进。
2020-02-12 08:39
ysr2857
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:34
帖 子:809
专家分:77
注 册:2020-2-10
收藏
得分:0 
回复 20楼 wmf2014
只要个总个数,不用打表,10^10内的。我都算了好几天了,10^9~10^10之间的都没有算出来,是朋友要这个数据的。谢谢您!祝您身体健康万事如意!
2020-02-12 10:13
ysr2857
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:34
帖 子:809
专家分:77
注 册:2020-2-10
收藏
得分:0 
Copyright © 1999-2020, , All Rights Reserved



搜索博文/帖子/用户
 登录
VB实现FFT算法 转载

weixin_34245749

225次阅读 2013-04-17

关注
程序列如下:

Public Function fft(ByRef Data() As Double) As Double()
    ReDim ffft(128, 2) As Double
    Dim length As Integer
    length = UBound(Data, 1) + 1
'    Dim numArray(length - 1, 2) As Double
      
    Dim index As Integer
    Dim num5 As Integer
    Dim num6 As Integer
    Dim num7 As Integer
    Dim num10 As Integer
    Dim num3 As Integer
    Dim num2 As Integer
    Dim num11 As Integer
    Dim num9 As Integer
    num9 = length
      
    Dim num8 As Integer
    num8 = CInt(Math.Log(CDbl(num9)) / Math.Log(2#))
      
    Dim numArray2(128) As Double
    Dim numArray3(128) As Double
    Dim numArray4(128) As Double
    Dim numArray5(128) As Double
    For index = 0 To num9 - 1
        numArray2(index) = Data(index)
        numArray3(index) = 0#
    Next
    Dim a As Double
    Dim num14 As Double
      
   num14 = 6.28318530717959 / CDbl(num9)
    index = 0
    While index < (num9 \ 2)
        numArray4(index) = Math.Sin(a)
        numArray5(index) = Math.Cos(a)
        a = a + num14
        index = index + 1
    Wend
    num7 = num9
    num3 = 1
    For num2 = 1 To num8
        num7 = num7 / 2
        num6 = 0
        For num11 = 1 To num3
            num10 = 0
            index = num6
            While index <= ((num7 + num6) - 1)
                num5 = index + num7
                a = numArray2(index) - numArray2(num5)
                num14 = numArray3(index) - numArray3(num5)
                numArray2(index) = numArray2(index) + numArray2(num5)
                numArray3(index) = numArray3(index) + numArray3(num5)
                If num10 = 0 Then
                    numArray2(num5) = a
                    numArray3(num5) = num14
                Else
                    numArray2(num5) = (a * numArray5(num10)) + (num14 * numArray4(num10))
                    numArray3(num5) = (num14 * numArray5(num10)) - (a * numArray4(num10))
                End If
                num10 = num10 + num3
                index = index + 1
           Wend
            num6 = (num6 + num7) + num7
        Next
        num3 = num3 + num3
    Next
    num5 = num9 \ 2
    For index = 1 To (num9 - 1)
        num6 = num9
        If num5 < index Then
            Dim num12 As Double
              
          num12 = numArray2(index)
            numArray2(index) = numArray2(num5)
            numArray2(num5) = num12
            num12 = numArray3(index)
            numArray3(index) = numArray3(num5)
            numArray3(num5) = num12
        End If
        num6 = num6 / 2
        Do While num5 >= num6
            num5 = num5 - num6
            num6 = num6 / 2
            If num5 = 0 Then
                Exit Do
            End If
        Loop
        num5 = num5 + num6
    Next
    For index = 0 To num9 - 1
        numArray(index, 0) = numArray2(index)
        numArray(index, 1) = numArray3(index)
        numArray(index, 2) = ((numArray2(index)) ^ 2# + (numArray3(index)) ^ 2#) ^ 0.5
    Next
   fft = numArray
End Function

前面的程序的说明(原稿中复制过来的):
默认了数组为128
如果你需要动态,请
redim各数组

输入:一串数据
输出:FFT变换后的数据,1维是实部 ,2维是虚部

这是vb版快速傅立叶变换fft,不懂,也不知道输出啥结果,不知道是否可以用于大整数的快速乘法。

没有找到vb版的大整数快速乘法程序。

有vc版的,不懂。
2020-02-12 10:54
ysr2857
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:34
帖 子:809
专家分:77
注 册:2020-2-10
收藏
得分:0 
是不是输出素数占用了时间,不输出素数仅输出总个数就会快了?
2020-02-12 11:33
ysr2857
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:34
帖 子:809
专家分:77
注 册:2020-2-10
收藏
得分:0 
前面的这个程序如何调用?想试试能出啥结果,不知道如何用?
2020-02-12 13:38
ysr2857
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:34
帖 子:809
专家分:77
注 册:2020-2-10
收藏
得分:0 
找到一个vb程序,不知道是不是快速乘法程序,原文前面的是高精度vc版乘法程序,不懂,后面是这个程序,不知道是不是乘法程序。
Dim i, j, L(2), a(1000) As Integer, b(1000) As Integer, c(2000, 2000) As Integer, d(2000, 2000) As Integer, x(10000) As Integer, jieguo As String, y(10000) As Integer

Private Sub Command1_Click()

L(1) = Len(Text2.Text)

L(2) = Len(Text3.Text)

For i = 1 To L(1)

a(i) = Val(Mid(Text2.Text, L(1) - i + 1, 1))

Next i

For i = 1 To L(2)

b(i) = Val(Mid(Text3.Text, L(2) - i + 1, 1))

Next i

For i = 1 To L(2)

For j = 1 To L(1)

c(i, j) = b(i) * a(j) + c(i, j)

d(i, j) = Int(c(i, j) / 10)

If d(i, j) > 0 Then

c(i, j) = c(i, j) - 10 * d(i, j)

c(i, j + 1) = c(i, j + 1) + d(i, j)

End If

d(i, j) = 0

Next j

Next i

For i = 1 To L(2)

b(i) = 0

Next i

For i = 1 To L(1)

a(i) = 0

Next i

For i = 1 To L(2)

For j = 1 To L(1) + 1

x(i + j - 1) = x(i + j - 1) + c(i, j)

c(i, j) = 0

Next j

Next i

For i = 1 To L(1) + L(2) + 1

y(i) = Int(x(i) / 10)

If y(i) > 0 Then

x(i) = x(i) - 10 * y(i)

x(i + 1) = x(i + 1) + y(i)

End If

y(i) = 0

Next i

Text1.Text = ""

If x(L(1) + L(2) + 1) <> 0 Then Text1.Text = Text1.Text & x(L(1) + L(2) + 1)

If x(L(1) + L(2)) <> 0 Then Text1.Text = Text1.Text & x(L(1) + L(2))

For i = L(1) + L(2) - 1 To 1 Step -1

Text1.Text = Text1.Text & x(i)

Next i

For i = 1 To L(1) + L(2) + 1

x(i) = 0

Next i

L(1) = 0

L(2) = 0

jieguo = Text1.Text

End Sub

Private Sub Form_Load()

Text2.Text = "a"

Text3.Text = "b"

Text1.Text = "结果"

Command1.Caption = "计算"

Timer1.Interval = 1

"interval,是间隔,值只能为数字而不能是true

jieguo = "结果"

End Sub

Private Sub Timer1_Timer()

Text1.Text = jieguo

End Sub

经过我验证了一下,这个乘法的速度不快,还没有我的模仿手工计算的乘法速度快,且大整数超过不知道多少位就会下标越界。太大话不能用了。

[此贴子已经被作者于2020-2-12 17:57编辑过]

2020-02-12 16:47
快速回复:各位老师好!求助编辑一个大整数的快速乘除法可调用程序
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019989 second(s), 9 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved