User:Arseniiv/Factorization/Doc: Difference between revisions

From Xenharmonic Wiki
Jump to navigation Jump to search
Arseniiv (talk | contribs)
updated for mk2
Arseniiv (talk | contribs)
m subst was a bad idea as all other functions weren’t substituted :D
Line 10: Line 10:
|-
|-
| <pre>{{Factorization|2^3 5 23^-3 31}}</pre>
| <pre>{{Factorization|2^3 5 23^-3 31}}</pre>
| {{#replace: {{#regex: {{#regex: 2^3 5 23^-3 31|/(\d+)\s*(?:(?:\*\*{{!}}\^)\s*([-−]?\d+))?(?:\s*\*)?\s*/u|\1<sup>\2</sup> ⋅&nbsp;}}|/\s⋅&nbsp;$/u|}}|-|−}}
| {{Factorization|2^3 5 23^-3 31}}
|-
|-
| <pre>{{Factorization| 2**3 * 5 * 7**-5 * 11**9 19**-4 }}</pre>
| <pre>{{Factorization| 2**3 * 5 * 7**-5 * 11**9 19**-4 }}</pre>
| {{#replace: {{#regex: {{#regex:  2**3 * 5 * 7**-5 * 11**9 * 19**-4 |/(\d+)\s*(?:(?:\*\*{{!}}\^)\s*([-−]?\d+))?(?:\s*\*)?\s*/u|\1<sup>\2</sup> ⋅&nbsp;}}|/\s⋅&nbsp;$/u|}}|-|−}}
| {{Factorization| 2**3 * 5 * 7**-5 * 11**9 * 19**-4 }}
|-
|-
| <pre>{{Factorization|3*7^-2*11*13^-1}}</pre>
| <pre>{{Factorization|3*7^-2*11*13^-1}}</pre>
| {{#replace: {{#regex: {{#regex: 3*7^-2*11 13^-1|/(\d+)\s*(?:(?:\*\*{{!}}\^)\s*([-−]?\d+))?(?:\s*\*)?\s*/u|\1<sup>\2</sup> ⋅&nbsp;}}|/\s⋅&nbsp;$/u|}}|-|−}}
| {{Factorization|3*7^-2*11 13^-1}}
|-
|-
| <pre>{{Factorization}}</pre>
| <pre>{{Factorization}}</pre>
| {{#replace: {{#regex: {{#regex: 1|/(\d+)\s*(?:(?:\*\*{{!}}\^)\s*([-−]?\d+))?(?:\s*\*)?\s*/u|\1<sup>\2</sup> ⋅&nbsp;}}|/\s⋅&nbsp;$/u|}}|-|−}}
| {{Factorization}}
|}
|}

Revision as of 23:12, 7 November 2020

This template outputs prime factorization in a pleasant form, given a plain-text expression.

For multiplication use * or simply space. For exponentiation use ** or ^. You can add extra spaces around all these, just not between - and an exponent.

One of good choices to write a readable source text is using spaces between factors and no space around exponentiation (the first two examples below).

Input Output
{{Factorization|2^3 5 23^-3 31}}
Lua error in Module:Utils at line 175: attempt to compare nil with number.
{{Factorization| 2**3 * 5 * 7**-5 * 11**9 19**-4 }}
Lua error in Module:Utils at line 175: attempt to compare nil with number.
{{Factorization|3*7^-2*11*13^-1}}
Lua error in Module:Utils at line 175: attempt to compare nil with number.
{{Factorization}}
22 × 3