Talk:Special factorials: Difference between revisions

→‎Reverse factorial algorithm: Fixed syntax highlighting
No edit summary
(→‎Reverse factorial algorithm: Fixed syntax highlighting)
 
Line 1:
=== Reverse factorial algorithm ===
I took a stab at translating the reverse factorial algorithm used in the Factor entry to Java. It should be almost as efficient as taking the factorial itself.
<syntaxhighlight lang="java">
<lang java>public static int rf(int n) {
if (n == 1)
return 0; //1 has two answers -- return the lower one
Line 14 ⟶ 15:
return b;
else return -1; //undefined
}</lang>
</syntaxhighlight>
--[[User:Chunes|Chunes]] ([[User talk:Chunes|talk]]) 17:06, 16 March 2021 (UTC)
 
3,037

edits