mersenneforum.org Large number division
 Register FAQ Search Today's Posts Mark Forums Read

 2022-07-20, 20:31 #1 science_man_88     "Forget I exist" Jul 2009 Dartmouth NS 2·3·23·61 Posts Large number division Code: div(n,x)=if(n<=10^znorder(Mod(10,x)),return(n),return(n%(10^znorder(Mod(10,x)))+div(floor(n/(10^znorder(Mod(10,x)))),x))) Implementation of the first step of https://math.stackexchange.com/quest...152669#3152669
2022-07-20, 20:46   #2
paulunderwood

Sep 2002
Database er0rr

2×5×19×23 Posts

Quote:
 Originally Posted by science_man_88 Code: div(n,x)=if(n<=10^znorder(Mod(10,x)),return(n),return(n%(10^znorder(Mod(10,x)))+div(floor(n/(10^znorder(Mod(10,x)))),x))) Implementation of the first step of https://math.stackexchange.com/quest...152669#3152669
WB sm88.

I never know if to use my or local, but your code can be made better by:

Code:
div(n,x)=local(tz=10^znorder(Mod(10,x)));if(n<=tz,return(n),return(n%tz+div(floor(n/tz),x)))
I think znorder requires factorisation,

Last fiddled with by science_man_88 on 2022-07-20 at 21:10

2022-07-20, 20:54   #3
science_man_88

"Forget I exist"
Jul 2009
Dartmouth NS

2×3×23×61 Posts

Quote:
 Originally Posted by paulunderwood WB sm88. I never know if to use my or local, but your code can be made better by: Code: div(n,x)=local(tz=10^znorder(Mod(10,x)));if(n<=tz,return(n),return(n%tz+div(floor(n/tz),x))) I think znorder requires factorisation,
Probably but x is prime in that use case no factorization overlap.

Last fiddled with by science_man_88 on 2022-07-20 at 21:11

 Similar Threads Thread Thread Starter Forum Replies Last Post craneduitre Msieve 23 2016-07-10 08:13 EdH GMP-ECM 43 2013-03-01 14:27 VolMike YAFU 18 2012-04-09 21:39 Dougal Conjectures 'R Us 1 2010-06-17 21:48 MavsFan Math 3 2003-12-12 02:23

All times are UTC. The time now is 09:47.

Thu Dec 1 09:47:15 UTC 2022 up 105 days, 7:15, 0 users, load averages: 0.99, 0.80, 0.79