This site is supported by donations to The OEIS Foundation.

Template:Divisor function

From OeisWiki
(Redirected from Template:Sigma k)
Jump to: navigation, search
The following documentation is located at Template:Divisor function/doc.
The {{divisor function}} arithmetic function template returns σk (n) for
k   ≠   0
of a nonzero integer, otherwise returns an error message. For
k = 0
, see {{number of divisors}} or {{sigma 0}} or {{tau}} arithmetic function template.

Usage

{{sigma k|a nonzero integer|k = a nonzero integer (default 1)}}

or

{{divisor function|a nonzero integer|k = a nonzero integer (default 1)}}

or

{{sigma k|a nonzero integer}}

or

{{divisor function|a nonzero integer}}
and for
k = 0
use
{{number of divisors|a nonzero integer}} or {{sigma 0|a nonzero integer}} or {{tau|a nonzero integer}}

Valid input

A nonzero integer less than 1031 2 = 1062961 (validation is done by the {{mpf}} arithmetic function template).

Examples

Examples with valid input (check for
k   ≥   1
with Divisor function#Table of sequences)
Divisor function sequences
k
A-number
0 A000005
 (n)
1 A000203
 (n)
2 A001157
 (n)
3 A001158
 (n)
4 A001159
 (n)
5 A001160
 (n)
6 A013954
 (n)
7 A013955
 (n)
8 A013956
 (n)

Unfortunately, with the transclusion of {{number of divisors/doc}} via the {{documentation}} template the precious limited nesting levels of templates and/or parser functions were exhausted! :-( Check {{number of divisors/doc}} directly to see that all the tests are successful. Fortunately, by transcluding {{number of divisors/doc}} directly, borrowing the minimum code needed here from the {{documentation}} template, we manage to not exhaust the limit! :-)

Code Result
{{divisor function|24|k = 3}} 16380
{{divisor function|24|k = 2}} 850
{{divisor function|24|k = 1}} 60
{{divisor function|24}} 60
{{divisor function|210^2}} 160797
{{divisor function|210^2}} 160797
{{divisor function|-28}} 56
{{divisor function|-5}} 6
{{divisor function|1}} 1
{{divisor function|7}} 8
{{divisor function|15}} 24
{{divisor function|27}} 40
{{divisor function|30}} 72
{{divisor function|111}} 152
{{sigma k|5^3 * 11^2}} 20748
{{sigma k|2^5 * 3^3 * 5}} 15120
{{sigma k|2^9 * 3^3}} 40920
{{sigma k|37^2 + 8 * 37^2}} 18291
{{sigma k|2^9 * (26 + 1)}} 40920
{{sigma k|89 * 113}} 10260
{{sigma k|79 * 79}} 6321
{{sigma k|210^2}} 160797
{{sigma k|233^2}} 54523
{{sigma k|10000}} 24211
{{sigma k|65535}} 111456
{{sigma k|65536}} 131071
{{sigma k|65537}} 65538
{{sigma k|65539}} 65540
{{sigma k|65540}} 143640
{{sigma k|65541}} 99904
{{sigma k|65542}} 98316
{{sigma k|65543}} 65544
{{sigma k|65547}} 94692
{{sigma k|65549}} 73440
{{sigma k|65551}} 65552
{{sigma k|65553}} 87408
{{sigma k|65557}} 65558
{{sigma k|65559}} 96488
{{sigma k|65561}} 66852
{{sigma k|65563}} 65564
{{sigma k|65567}} 66120
{{sigma k|65569}} 86400
{{sigma k|65571}} 95424
{{sigma k|65573}} 68448
{{sigma k|65577}} 87440
{{sigma k|65579}} 65580

Examples with invalid input (argument validation by {{divisor function}} is omitted to spare some precious limited nesting levels of templates and/or parser functions).

Code Result
{{sigma k|0}} Expression error: Unexpected < operator.
{{sigma k|1031^2}} Expression error: Unexpected < operator.

Code


<noinclude><!-- {{documentation}} --><!-- We can't use it here, we reached the nesting levels limit of templates and/or parser functions! 

So we just borrow the necessary code from it instead.

--><div style="text-align: center; font-size: smaller;">The following [[Help:Documenting templates|documentation]] is located at [[Template:{{PAGENAME}}/doc]].</div>{{Template:{{PAGENAME}}/doc}}<!--

:<math> \sigma_k(n) = \begin{cases}
\prod_{i=1}^{\omega(n)} (1 + \alpha_i) & \text{if } k = 0, \\
\prod_{i=1}^{\omega(n)} \frac{p_{i}^{k (1+ \alpha_i)} - 1}{p_{i}^{k} - 1} & \text{if } k > 0. \end{cases}</math>

For k = 0, we have a separate arithmetic function template: [[Template:Number of divisors]]

The following code is very inefficient, we call [[Template:mpf]] twice! To avoid this we would need a core function template to which we pass the result of [[Template:mpf]] to one of its arguments, but this requires one more templates and/or parser functions nesting level, unfortunately we've reached the limit! :-(

For -1 or +1, [[Template:mpf]] returns the empty string, so we use an ugly kludge (without adding a nesting level around [[Template:mpf]]) to get 1 as result, and to balance parenthesis. I admit that templates are no scripting language, and using templates to implement arithmetic functions is like using a screwdriver to hammer a nail...  

--></noinclude><includeonly>{{#expr: 
( 
  ( {{#ifexpr: abs ({{{1|1}}}) = 1 | ( ( 2 }}{{mpf| {{{1|1}}} |sep = ) ) - 1) * ( |key/val_sep = ^( ({{{k|{{{2|1}}}}}}) * (1 + }} ) ) - 1) 
) 
/ 
( 
  ( {{#ifexpr: abs ({{{1|1}}}) = 1 | ( 2 }}{{mpf| {{{1|1}}} |sep = ) - 1) * ( |key/val_sep = ^( ({{{k|{{{2|1}}}}}}) * 1^ }} ) - 1) 
) 
}}</includeonly>

See also







External links