This site is supported by donations to The OEIS Foundation.

Template:Multiplicity

From OeisWiki

Jump to: navigation, search
The following documentation is located at Template:Multiplicity/doc. [Edit Template:Multiplicity/doc]
[<Purge> Template:Multiplicity]

The {{multiplicity}} arithmetic function template returns the multiplicity of a [potential] nonzero integer factor (how many times we can divide by the given [potential] factor) of an integer. (It returns 0 for a nonfactor.) Note that −1 or 1 as [potential] factor always give multiplicity INF, which stands for infinity! Also, any nonzero integer as [potential] factor of 0 has multiplicity INF.

Contents

Usage

{{multiplicity|an integer|factor = a nonzero integer factor}}

or

{{multiplicity|an integer|a nonzero integer factor}}

Examples

Examples with valid input

Code Result
{{multiplicity|-2|1}} INF
{{multiplicity|-2|5}} 0
{{multiplicity|-1|1}} INF
{{multiplicity|-1|5}} 0
{{multiplicity|0|1}} INF
{{multiplicity|0|5}} INF
{{multiplicity|1|1}} INF
{{multiplicity|1|5}} 0
{{multiplicity|2|1}} INF
{{multiplicity|2|5}} 0
{{multiplicity|-28|-1}} INF
{{multiplicity|-28|1}} INF
{{multiplicity|-28|-2}} 2
{{multiplicity|-28|2}} 2
{{multiplicity|-28|-4}} 1
{{multiplicity|-28|4}} 1
{{multiplicity|-28|-8}} 0
{{multiplicity|-28|8}} 0
{{multiplicity|-28|-7}} 1
{{multiplicity|-28|7}} 1
{{multiplicity|-28|-28}} 1
{{multiplicity|-28|28}} 1
{{multiplicity|210|2}} 1
{{multiplicity|210|3}} 1
{{multiplicity|210|5}} 1
{{multiplicity|210|7}} 1
{{multiplicity|210|11}} 0
{{multiplicity|121|11}} 2
{{multiplicity|1000|2}} 3
{{multiplicity|1000|3}} 0
{{multiplicity|1000|5}} 3
{{multiplicity|5 * 7^3 * 13 * 29|7}} 3
{{multiplicity|5 * 7^3 * 13 * 29|29}} 1
{{multiplicity|2 * 3^7 * 5^3 * 29|3}} 7
{{multiplicity|2 * 3^7 * 5^3 * 29|5}} 3
{{multiplicity|2^5 * 3^11 * 29|2}} 5
{{multiplicity|2^5 * 3^11 * 29|6}} 5
{{multiplicity|2^5 * 3^11 * 29|36}} 2
{{multiplicity|2^5 * 3^11 * 29|3}} 11
{{multiplicity|2^5 * 3^11 * 29|9}} 5
{{multiplicity|2^5 * 3^12 * 29|27}} 4
{{multiplicity|2^5 * 3^12 * 29|3^6}} 2
{{multiplicity|2^5 * 3^11 * 29|27}} 3
{{multiplicity|2^5 * 3^11 * 29|29}} 1
{{multiplicity|11 * 37^2|37}} 2
{{multiplicity|11 * 37^2|31}} 0
{{multiplicity|3^2 * 11 * 23 * 71|23}} 1
{{multiplicity|3^2 * 11 * 23 * 71|3}} 2
{{multiplicity|- (3^2 * 11 * 23 * 71)|3}} 2
{{multiplicity|3^2 * 11 * 23 * 71|-3}} 2
{{multiplicity|- (3^2 * 11 * 23 * 71)|-3}} 2
{{multiplicity|2^31|2}} 31
{{multiplicity|2^30 + 2^30|2}} 31
{{multiplicity|5^3 * 2^17|2}} 17
{{multiplicity|121 + 7|2}} 7

Examples with invalid input

Code Result
{{multiplicity|-2|0}} Multiplicity error: Second argument (factor) must be a nonzero integer
{{multiplicity|-1|0}} Multiplicity error: Second argument (factor) must be a nonzero integer
{{multiplicity|0|0}} Multiplicity error: Second argument (factor) must be a nonzero integer
{{multiplicity|1|0}} Multiplicity error: Second argument (factor) must be a nonzero integer
{{multiplicity|2|0}} Multiplicity error: Second argument (factor) must be a nonzero integer
{{multiplicity|2^32|0}} Multiplicity error: First argument must be an integer less than 232 = 4294967296
{{multiplicity|2^32|1}} Multiplicity error: First argument must be an integer less than 232 = 4294967296
{{multiplicity|2^32|2}} Multiplicity error: First argument must be an integer less than 232 = 4294967296
{{multiplicity|2^32|3}} Multiplicity error: First argument must be an integer less than 232 = 4294967296

Formatted numbers

This template requires unformatted numbers, it will not recognize formatted numbers, e.g. comma separated, which is by design since formatted numbers will break expression parsers. To remove the formatting from a number, you can wrap the number first in {{formatnum:number|R}}.[1]

code result
{{multiplicity|1,000|5}} Multiplicity error: First argument must be an integer
{{multiplicity|{{formatnum:1,000|R}}|5}} 3

Code


{{ifint| {{{1|NAN}}}
| {{ifint| {{{factor|{{{2|NAN}}}}}}
  | {{#ifexpr: ( ( abs ({{{1}}}) ) > 0 ) and ( ( abs ({{{1}}}) ) < 2^32 ) and ( ( abs ({{{factor|{{{2}}}}}}) ) > 1 )
    | {{#ifexpr: ( ({{{1}}}) mod ({{{factor|{{{2}}}}}}) ) = 0 
      | {{#expr: 1 + <!-- at least once -->          

          {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(32/ 2) 
          |  
            ( 0^( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^2 ) ) ) )

            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/ 3)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^ 3 ) ) ) | 0 }}
          | 0
          }} +

          {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(32/ 4) 
          |  
            ( 0^( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^4 ) ) ) )

            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/ 5)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^ 5 ) ) ) | 0 }}
            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/ 6)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^ 6 ) ) ) | 0 }}
            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/ 7)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^ 7 ) ) ) | 0 }}
          | 0
          }} +

          {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(32/ 8) 
          |  
            ( 0^( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^8 ) ) ) )

            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/ 9)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^ 9 ) ) ) | 0 }}

            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/10)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^10 ) ) ) | 0 }}
            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/11)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^11 ) ) ) | 0 }}
            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/12)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^12 ) ) ) | 0 }}
            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/13)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^13 ) ) ) | 0 }}
            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/14)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^14 ) ) ) | 0 }}
            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/15)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^15 ) ) ) | 0 }}
          | 0
          }} +

          {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(32/ 16) 
          |  
            ( 0^( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^16 ) ) ) )

            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/17)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^17 ) ) ) | 0 }}
            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/18)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^18 ) ) ) | 0 }}
            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/19)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^19 ) ) ) | 0 }}

            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/20)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^20 ) ) ) | 0 }}
            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/21)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^21 ) ) ) | 0 }}
            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/22)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^22 ) ) ) | 0 }}
            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/23)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^23 ) ) ) | 0 }}
            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/24)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^24 ) ) ) | 0 }}
            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/25)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^25 ) ) ) | 0 }}
            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/26)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^26 ) ) ) | 0 }}
            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/27)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^27 ) ) ) | 0 }}
            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/28)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^28 ) ) ) | 0 }}
            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/29)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^29 ) ) ) | 0 }}

            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/30)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^30 ) ) ) | 0 }}
            + {{#ifexpr: ( abs ({{{factor|{{{2}}}}}}) ) <= 2^(floor(32/31)) | not ( abs ( ({{{1}}}) mod ( ({{{factor|{{{2}}}}}})^31 ) ) ) | 0 }}
          | 0
          }}

        }}
      | 0 <!-- none -->
      }}
    | {{#ifexpr: ( abs ({{{1}}}) ) = 0 and ( ( abs ({{{factor|{{{2}}}}}}) ) > 0 )
      | INF
      }}<!--
   -->{{#ifexpr: ( abs ({{{1}}}) ) >= 2^32
      | {{error| Multiplicity error: First argument must be an integer less than 2{{^|32}} {{=}} {{#expr: 2^32 }} }} 
      }}<!--
   -->{{#ifexpr: ( ( abs ({{{1}}}) ) < 2^32 ) and ( ( abs ({{{factor|{{{2}}}}}}) ) = 0 )  
      | {{error| Multiplicity error: Second argument (factor) must be a nonzero integer }}  
      }}<!--
   -->{{#ifexpr: ( ( abs ({{{1}}}) ) > 0 ) and ( ( abs ({{{1}}}) ) < 2^32 ) and ( ( abs ({{{factor|{{{2}}}}}}) ) = 1 )  
      | INF 
      }}
    }}
  | {{error| Multiplicity error: Second argument (factor) must be a nonzero integer }} 
  }}
| {{error| Multiplicity error: First argument must be an integer }}
}}

See also



  • {{multiplicity}}





External links

Notes

  1. Help:Magic words#FormattingMediaWiki.org.
Personal tools