bigdata - Fortran 95: super large numbers for prime test -


i'm pretty new fortran, in started learning 2 days ago new. started learning fortran because getting prime numbers, , wrote program in python fast, determine 123098237 prime in 0.1 seconds. impressive, know. what's not impressive when try find out if (2^127)-1 or 170141183460469231731687303715884105727 (it is, way) prime number. program ran long, ended having stop it. so, started looking faster languages write in, wrote program in c. faster, problem of super large prime numbers came play. going to see if there solution heard through grapevine that, if programming numbers, fortran fastest , best way go. vaguely remember step dad's old fortran 77 text books college, useless me, because talking working punch cards. so, went online, got gfortran ubuntu 12.04 x86, got couple of pdfs, , started learning. before know made program received input , tested primality, , worked! but, same old problem came up, number big. , so, how handle big numbers fortran?

fortran, many other compiled languages, doesn't provide such large integers or operations on them out-of-the-box. date compiler ought provide integer 18 decimal digits, no more that.

if want program, in fortran, data types , operations such big integers use favourite search engine on terms such fortran multiple precision. search around here on relevant questions , answers.

if want investigate mathematics of such large integers stick python; you'll struggle write software matches speed of operations on multiple precision arithmetic. 1 of reasons python takes long time determine primality of large number takes program, program written in language, long time determine primality of large number. if dig around you're find relevant python routines call code written in c or low-level. investigate, if wish, topic of computational complexity of primality testing.

i'm not saying won't able write code outperform python intrinsics, find challenge.


Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -