faster_prog.sf 5.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #!/usr/bin/ruby
  2. # Least Lucas number with n Lucas divisors
  3. # https://oeis.org/A356123
  4. func count_lucas_divisors(n) {
  5. var count = 0
  6. for k in (0..Inf) {
  7. var t = k.lucas
  8. if (t.divides(n)) {
  9. ++count
  10. }
  11. break if (t >= n)
  12. }
  13. return count
  14. }
  15. func a(n) {
  16. return 1 if (n == 1)
  17. return 2 if (n == 2)
  18. 0..Inf -> first_by {|k|
  19. count_lucas_divisors(k.lucas) == n
  20. }.lucas
  21. }
  22. for n in (1..100) {
  23. say "#{n} #{a(n)}"
  24. }
  25. __END__
  26. # PARI/GP program:
  27. countLd(n) = my(c=0,x=2,y=1); while(x <= n, if(n%x == 0, c++); [x,y]=[y,x+y]); c;
  28. a(n) = if(n==1, return(1)); my(x=2,y=1); while(1, if(countLd(x) == n, return(x)); [x,y]=[y,x+y]); \\ ~~~~
  29. 1 1
  30. 2 2
  31. 3 4
  32. 4 18
  33. 5 1364
  34. 6 1860498
  35. 7 2537720636
  36. 8 6440026026380244498
  37. 9 8784200221406821330636
  38. 10 77162173529763648886126034136172445632164498
  39. 11 4365101043708483494615466932242949707161871659736799144058331102381689400753867700636
  40. 12 19054107121784891932090468041873964553830353178975673058414325567410566480137142507003826854339595445525717389132261399044637834164778377296454582982585426862209714804498
  41. 13 677807981804381412733419097483256033462649109976189806684020291364
  42. 14 459423660197728644284562436534947029675371105950380039166426064277162387143841524607797188115576601372734896873257029765691452980498
  43. 15 575371983682999713995277373343141798109328411107261262710709763338723097807776869622073930682474635855300557299942525312980698073465161617489234464671252150826903147876642105158324597742107236269075730966380877724949420843008193415271005956411655425694692862152177904877989836591984410372390528129015656195623595879001993711921459090781772952473819240765980529756482283161971216394758618254188931192599095750873312805537240645208460792218028241083759652934979582405349716411762135749101757905255078618290245455713897153177868613200017593364416624616315703920538137199361376761320503200641362283124539996992335260611554992015000033604252846312658622262420857611839392120996011153218446889076283282650764965905623695324265655409763275971889195028281905078896080636
  44. 16 1584789212007477853349053494387375307203166608597260884221238425732196253278613441589199214939678794811890035054791248593644068028534613033524860608194432161282510668294540015164641981843096158499233919452860373553242048102127183493691770386524381876113867657240479935278163970340125898373418902565788545339599191333980458977179443445272806265559288037250780012107618076897495867186141815231190195255939447741829417149714636
  45. 17 311401023911804366001393706883327384076615734808934133163016625077374917684621775749047715948426742649586980511394972805404487468982808751295850548939794653822395590692587746271928911839432190110636
  46. 18 96970597693320154528788041357664110133030365630508442349902877557364153915220316867760931542133108061026572864124553835516659308188747679003204271425837892990461335527176933458876508100122914244051415560927752006140058313510988622594584598006776458459660944725551259651729062332558950629424815283707772606795276979400337762402108466853558167691805280828759021795440067818835788730939557920324498
  47. 19 143064998194881581319245548903861091867159441321906177576348349748955744888755160576112945481283258381262413576608604270966260849023534681903442308950353491236755326489870808933231784042436061126044304254574335799257720579725987351462776900362116807516549457787145906238616424768034005572848040287319265432643386346696338550085364
  48. 20 20467593708501470121328234368369294297618217146643361105059646135431540791027409776847536332599958760019752847524263394255917494418724025266038000977608259534539195782306630103727680823657313834256910370012612435135954502309508024963074476249385541953120300584923230484664710377260712596124264698633928171980027857031812998253472161499512984495074767197234370608684592404769919039868509542492938971091587541176728330255586137636445578716159758583817619720308235024884634155093223446033086483227766874286847541716021739614394504788969556764548911757980191214518241608264596037224168876717186111403799841883168459279290513256711895796104040414874987971687012498
  49. 21 30196743411039550737316673553572072436391124165700071953158611111678619159451191630097808894984409643607221564194638215090415685264924629145685996849755028675250415767091545395830663110400322188541103194263404028238766744988441674779760527059363399094590976552832513215977931586619641064652252627221890595997012363672130256529829980687582324603135280846555137167046579115170449101498721449810900650117926217081741254801298477548970107400870539163890576331539824782258529818499426569930244069708126210229002550505863113708174819394557460571272542138647824538025071079149964416657636295831271364
  50. 22 911843312632160521853936472159353160228381441573458313300898231829297643440377583489099073053824663851736287014149978557924871133517479963230364651217467900235992709693079768060605775018227120547307336852015243502488614814426878512448212812860440892488943336113479671018749235657845457397379094011854731123172633520542576293983612344250497643682122125072180251398109493919713266517894245396599296187015280131666308380293145903965606203133744463551838103568858241579963105076303808271926072715806818662936948240084261658810558705081798296650161649673710985812596105205858901241497473278643159442520144015493963623114964411569776857229952220821138003081213670290288444714993973940803501325615477482858809728211308877587504513042298027959915246847487287693556720460746772788466974624181628952527093085163048560140114234331140485791789486739618567306237417189393040909457639414183834999190619727321275653697309704814695265399653141913860744709459616213312527408432904021242981502187735725725984233579030341124635573921369289150429918626412138073185060593828551150082502922910001777168405606020532159945565431865460092192110581532377313140236215987431156596528698874242313612124840606420498