Talk:Factors of an integer: Difference between revisions

added a section header name for the first talk section to force the __TOC__ to the proper place.
(→‎task description: added a better wording, added note about semi-primes.)
(added a section header name for the first talk section to force the __TOC__ to the proper place.)
 
(7 intermediate revisions by 3 users not shown)
Line 1:
==Should this be "Basic language learning"?==
Should this be "Basic language learning"? I don't even know.
[[User:Oligomous|Oligomous]] 12:10, 15 August 2009 (UTC)
Line 23 ⟶ 24:
 
<br><br>Also, worthy of note is: &nbsp; All &nbsp; '''semiprimes''' &nbsp; (also known as '''biprimes''' or '''2-almost primes''') &nbsp; have exactly three factors: &nbsp; unity and two (not necessarily distinct) primes. &nbsp; -- [[User:Gerard Schildberger|Gerard Schildberger]] ([[User talk:Gerard Schildberger|talk]]) 23:23, 14 June 2015 (UTC)
 
: I made the wording more verbose to avoid the issue with the word "even". Of course, this leaves open issues such as factors of non-integers, and verbosity sometimes makes problems worse. But maybe it's good enough for now? --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 15:12, 15 June 2015 (UTC)
 
==Python relative performance==
Hi Ledrug, care to join us over on [[Talk:Proper_divisors#Python:_comparisons]]... --[[User:Paddy3118|Paddy3118]] ([[User talk:Paddy3118|talk]]) 08:45, 20 December 2014 (UTC)
 
== fix bug in k ( kx.com's dialect of APL ) ==
 
The code <lang K> f:{d:&~x!'!1+_sqrt x;?d,_ x%|d}</lang>
was not working with current KDB version .. "~x!'" gives a type error
"q" is a literate wrapper for "k" so I provided that to make it clearer what the code is doing
<lang K>q) f:{i:{y where x=y*x div y}[x ; 1+ til floor sqrt x]; distinct i,x div reverse i}</lang>
 
== Formatting very wide Haskell lines ==
 
Very nice final list comprehension example there. Thanks !
 
Perhaps Johan Tibell style (https://github.com/tibbe/haskell-style-guide) or hindent (http://chrisdone.com/posts/hindent-5) to bring the 97-character within the 80 character Rosetta guidelines, and for ease of reading ? (PS maybe that Data.List import is not needed with current default builds of GHC ? Those functions all seem to be Prelude default)
 
<lang haskell>factors_o :: Integral a => a -> [a]
factors_o n =
ds ++
[ r
| (d, 0) <- [divMod n r]
, r <-
r :
[ d
| d > r ] ] ++
reverse (map (n `div`) ds)
where
r = floor (sqrt (fromIntegral n))
ds =
[ i
| i <- [1 .. r - 1]
, mod n i == 0 ]</lang>
 
: A rare 97 character line does not seem like a problem, to me. --[[User:Rdm|Rdm]] ([[User talk:Rdm|talk]]) 16:29, 29 December 2016 (UTC)