Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Prime factors in 25 lines or less
#26
Quote:I have enhanced my post by using DOUBLEs to be able to factorize values up to 5e15. By using ffix it declares 4999999999999997 prime in 12 seconds in my computer ..I hope it's really prime...

EDITED: It is. You can check your factorizations here http://www.alpertron.com.ar/ECM.HTM
Code:
declare sub ffix()
declare sub checkf(k#)

dim shared x#,C#
ffix
do
  print
   INPUT "enter a number to factorize[0 to end] : ", x#
   if x#<=0 or x#>5E15 then exit do
   t!=timer:c#=1
   PRINT "the prime factors are:";
   checkf(2#)
   checkf(3#)
   a#=2
   k# = 3 + a#
   WHILE K# <= sqr(x#)
     checkf(k#)
     k# = k# + a#
     a#=6#-a#
   WEND
   if x#>1 then print x#;:c#=c#*x#
   print: PRINT "Ended in ";timer-t!;" seconds. Product of all factors: "; C#
loop
sleep
sub checkf(k#)
do
  x1# = x# / k#
  if x1#-int(x1#)>1e-15 then exit do
  PRINT k#;
  C#=C#*K#
  x#=x1#
loop
end sub
I hope no round-off errors are experienced with those floating-point numbers. :roll:
974277320612072617420666C61696C21 (Hexadecimal for those who don't know)
Reply


Messages In This Thread
Prime factors in 25 lines or less - by whodat - 10-07-2005, 10:21 PM
Prime factors in 25 lines or less - by Agamemnus - 10-08-2005, 07:05 AM
from an ageing newbie - by whodat - 10-09-2005, 02:41 AM
Prime factors in 25 lines or less - by Agamemnus - 10-09-2005, 02:49 AM
Prime factors in 25 lines or less - by whodat - 10-09-2005, 03:08 AM
Prime factors in 25 lines or less - by neuro - 10-09-2005, 03:35 AM
Prime factors in 25 lines or less - by speedlemon - 10-09-2005, 03:51 AM
Prime factors in 25 lines or less - by Agamemnus - 10-09-2005, 04:11 AM
Prime factors in 25 lines or less - by whodat - 10-09-2005, 05:41 AM
I like it - by whodat - 10-09-2005, 05:57 AM
Am I doing something wrong? - by whodat - 10-09-2005, 06:06 AM
Prime factors in 25 lines or less - by rpgfan3233 - 10-09-2005, 10:27 AM
Prime factors in 25 lines or less - by d.j.peters - 10-09-2005, 11:17 PM
Prime factors in 25 lines or less - by Agamemnus - 10-10-2005, 01:43 AM
Prime factors in 25 lines or less - by whodat - 10-10-2005, 02:01 AM
Prime factors in 25 lines or less - by Agamemnus - 10-10-2005, 02:13 AM
Prime factors in 25 lines or less - by whodat - 10-10-2005, 02:58 AM
Prime factors in 25 lines or less - by whodat - 10-10-2005, 03:04 AM
Prime factors in 25 lines or less - by Quibbler - 10-10-2005, 06:05 PM
Prime factors in 25 lines or less - by rpgfan3233 - 10-10-2005, 09:24 PM
Prime factors in 25 lines or less - by Quibbler - 10-10-2005, 09:37 PM
Prime factors in 25 lines or less - by Quibbler - 10-11-2005, 01:07 AM

Forum Jump:


Users browsing this thread: 1 Guest(s)