mersenneforum.org  

Go Back   mersenneforum.org > Extra Stuff > Programming

Reply
 
Thread Tools
Old 2008-12-30, 22:24   #1
starrynte
 
starrynte's Avatar
 
Oct 2008
California

EC16 Posts
Default coding midlet for TF

I finished the "powering algorithm" (described on the math page of GIMPS) , any suggestions for improvements in speed/size?
Code:
public boolean testFactor(int expo,int factor){
    String n=Integer.toBinaryString(expo); //the binary representation
    long temp=1;
    do{
        temp*=temp; //square
        temp<<=Integer.parseInt(n.substring(0,1)); //if the top bit is 1, multiply by 2
        temp%=factor; //mod <the test factor>
    }while((n=n.substring(1)).length()>0); //remove the top bit, and continue if there is still more to do
    return (temp==1)?true:false; //if the final result is 1, then the test factor was a factor!
}
(Still trying to work out the GUI and sieving)

Last fiddled with by starrynte on 2008-12-30 at 22:25
starrynte is offline   Reply With Quote
Old 2008-12-30, 22:31   #2
R. Gerbicz
 
R. Gerbicz's Avatar
 
"Robert Gerbicz"
Oct 2005
Hungary

7·229 Posts
Default

Quote:
Originally Posted by starrynte View Post
I finished the "powering algorithm" (described on the math page of GIMPS) , any suggestions for improvements in speed/size?
Use sliding windows. (In gmp it is already implemented, see it's source.)

Last fiddled with by R. Gerbicz on 2008-12-30 at 22:32
R. Gerbicz is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Anyone know enough about coding to do this? jrafanelli Software 2 2018-01-11 15:16
Python Coding Help? kelzo Programming 3 2016-11-27 05:16
LLR Midlet starrynte Programming 0 2010-12-14 06:17
Questions on coding my FFT&LLR implementation nuggetprime Programming 56 2008-10-27 22:45
Coding Challenges R.D. Silverman Programming 18 2005-08-09 13:14

All times are UTC. The time now is 18:41.


Sun Dec 4 18:41:22 UTC 2022 up 108 days, 16:09, 0 users, load averages: 0.83, 0.78, 0.88

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2022, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.

≠ ± ∓ ÷ × · − √ ‰ ⊗ ⊕ ⊖ ⊘ ⊙ ≤ ≥ ≦ ≧ ≨ ≩ ≺ ≻ ≼ ≽ ⊏ ⊐ ⊑ ⊒ ² ³ °
∠ ∟ ° ≅ ~ ‖ ⟂ ⫛
≡ ≜ ≈ ∝ ∞ ≪ ≫ ⌊⌋ ⌈⌉ ∘ ∏ ∐ ∑ ∧ ∨ ∩ ∪ ⨀ ⊕ ⊗ 𝖕 𝖖 𝖗 ⊲ ⊳
∅ ∖ ∁ ↦ ↣ ∩ ∪ ⊆ ⊂ ⊄ ⊊ ⊇ ⊃ ⊅ ⊋ ⊖ ∈ ∉ ∋ ∌ ℕ ℤ ℚ ℝ ℂ ℵ ℶ ℷ ℸ 𝓟
¬ ∨ ∧ ⊕ → ← ⇒ ⇐ ⇔ ∀ ∃ ∄ ∴ ∵ ⊤ ⊥ ⊢ ⊨ ⫤ ⊣ … ⋯ ⋮ ⋰ ⋱
∫ ∬ ∭ ∮ ∯ ∰ ∇ ∆ δ ∂ ℱ ℒ ℓ
𝛢𝛼 𝛣𝛽 𝛤𝛾 𝛥𝛿 𝛦𝜀𝜖 𝛧𝜁 𝛨𝜂 𝛩𝜃𝜗 𝛪𝜄 𝛫𝜅 𝛬𝜆 𝛭𝜇 𝛮𝜈 𝛯𝜉 𝛰𝜊 𝛱𝜋 𝛲𝜌 𝛴𝜎𝜍 𝛵𝜏 𝛶𝜐 𝛷𝜙𝜑 𝛸𝜒 𝛹𝜓 𝛺𝜔