Currently there may be errors shown on top of a page, because of a missing Wiki update (PHP version and extension DPL3).
Navigation
Topics Help • Register • News • History • How to • Sequences statistics • Template prototypes

Difference between revisions of "Template:Kbn"

From Prime-Wiki
Jump to: navigation, search
m
(± added)
 
(5 intermediate revisions by the same user not shown)
Line 1: Line 1:
 
<noinclude>
 
<noinclude>
 
==Purpose==
 
==Purpose==
Display numbers of the form k &times; b<sup>n</sup>±1 in text-mode.
+
Display numbers of the form {{Vk}}•{{Vb}}<sup>{{Vn}}</sup>±1 in text-mode.
  
 
==Usage==
 
==Usage==
This templates uses one to four unnamed parameters which are defined as follows:
+
This template uses one to four unnamed parameters which are defined as follows:
*Only if the first parameter is {{Key|+}}, the '+'-value is displayed, otherwise the '-'-value of the number.
+
*Only if the first parameter is {{Key|+}} or {{Key|±}}, the '+'/'±'-value is displayed, otherwise the '-'-value of the number.
Three more parameters cotaining numbers can be given and used as follows:
+
Three more parameters containing numbers/variables can be given and used as follows:
*one parameter: the n-value is given and displays as 2<sup>n</sup>±1
+
*one parameter: the {{Vn}}-value is given and displays as 2<sup>{{Vn}}</sup>±1
*two parameters: the k- and n-values are given and display as k &times; 2<sup>n</sup>±1
+
*two parameters: the {{Vk}}- and {{Vn}}-value are given and display as {{Vk}}•2<sup>{{Vn}}</sup>±1
*three parameters: the k-, b, and n-values are given and display as k &times; b<sup>n</sup>±1
+
*three parameters: the {{Vk}}-, {{Vb}}- and {{Vn}}-value are given and display as {{Vk}}•{{Vb}}<sup>{{Vn}}</sup>±1
  
 
==Examples==
 
==Examples==
*1 parameter: <code><nowiki>{{Kbn|123}}</nowiki></code>: {{Kbn|123}}
+
*one parameter: <code><nowiki>{{Kbn|123}}</nowiki></code>: {{Kbn|123}}
*2 parameters: <code><nowiki>{{Kbn|3|123}}</nowiki></code>: {{Kbn|3|123}}
+
*two parameters: <code><nowiki>{{Kbn|3|123}}</nowiki></code>: {{Kbn|3|123}}
*3 parameters: <code><nowiki>{{Kbn|3|5|123}}</nowiki></code>: {{Kbn|3|5|123}}
+
*three parameters: <code><nowiki>{{Kbn|3|5|123}}</nowiki></code>: {{Kbn|3|5|123}}
  
 
With '+'-sign:
 
With '+'-sign:
Line 20: Line 20:
 
*<code><nowiki>{{Kbn|+|13|123}}</nowiki></code>: {{Kbn|+|13|123}}
 
*<code><nowiki>{{Kbn|+|13|123}}</nowiki></code>: {{Kbn|+|13|123}}
 
*<code><nowiki>{{Kbn|+|3|5|123}}</nowiki></code>: {{Kbn|+|3|5|123}}
 
*<code><nowiki>{{Kbn|+|3|5|123}}</nowiki></code>: {{Kbn|+|3|5|123}}
 +
With '±'-sign:
 +
*<code><nowiki>{{Kbn|±|123}}</nowiki></code>: {{Kbn|±|123}}
 +
*<code><nowiki>{{Kbn|±|13|123}}</nowiki></code>: {{Kbn|±|13|123}}
 +
*<code><nowiki>{{Kbn|±|3|5|123}}</nowiki></code>: {{Kbn|±|3|5|123}}
  
 
Others:
 
Others:
*To display only {{Kbn|+|1|10|123}}, set the k-value to '1': <code><nowiki>{{Kbn|+|1|10|123}}</nowiki></code> (or <code><nowiki>{{Kbn|1|10|123}}</nowiki></code> to get {{Kbn|1|10|123}}).
+
*To display only {{Kbn|+|1|10|123}}, set the {{Vk}}-value to '1': <code><nowiki>{{Kbn|+|1|10|123}}</nowiki></code> (or <code><nowiki>{{Kbn|1|10|123}}</nowiki></code> to get {{Kbn|1|10|123}}).
  
 
Also possible:
 
Also possible:
*<code><nowiki>{{Kbn|2<sup>n</sup>}}</nowiki></code>: {{Kbn|2<sup>n</sup>}}
+
*<code><nowiki>{{Kbn|2<sup>{{Vn}}</sup>}}</nowiki></code>: {{Kbn|2<sup>{{Vn}}</sup>}}
*<code><nowiki>{{Kbn|+|2<sup>11</sup>}}</nowiki></code>: {{Kbn|+|2<sup>11</sup>}}
+
*<code><nowiki>{{Kbn|k|b|n}}</nowiki></code>: {{Kbn|k|b|n}}
 
+
*<code><nowiki>{{Kbn|+|k|b|n}}</nowiki></code>: {{Kbn|+|k|b|n}}
 +
*<code><nowiki>{{Kbn|1|b|n}}</nowiki></code>: {{Kbn|1|b|n}}
 +
*<code><nowiki>{{Kbn|+|(b-1)|b|n}}</nowiki></code>: {{Kbn|+|(b-1)|b|n}}
 
[[Category:Templates]]</noinclude><includeonly>{{#vardefine:args|0}}{{#if:{{{4|}}}|{{#vardefine:args|4}}|{{#if:{{{3|}}}|{{#vardefine:args|3}}|{{#if:{{{2|}}}|{{#vardefine:args|2}}|{{#vardefine:args|1}}}}}}}}{{#switch:{{#var:args}}
 
[[Category:Templates]]</noinclude><includeonly>{{#vardefine:args|0}}{{#if:{{{4|}}}|{{#vardefine:args|4}}|{{#if:{{{3|}}}|{{#vardefine:args|3}}|{{#if:{{{2|}}}|{{#vardefine:args|2}}|{{#vardefine:args|1}}}}}}}}{{#switch:{{#var:args}}
|1=2<sup>{{{1}}}</sup>-1
+
|1=2<sup>{{VarNum|{{{1}}}}}</sup>-1
|2={{#ifeq:{{{1}}}|+|2<sup>{{{2}}}</sup>+1|{{{1}}} &times; 2<sup>{{{2}}}</sup>-1}}
+
|2={{#ifeq:{{{1}}}|+|2<sup>{{VarNum|{{{2}}}}}</sup>+1|{{#ifeq:{{{1}}}|±|2<sup>{{VarNum|{{{2}}}}}</sup>±1|{{VarNum|{{{1}}}}}•2<sup>{{VarNum|{{{2}}}}}</sup>-1}}}}
|3={{#ifeq:{{{1}}}|+|{{{2}}} &times; 2<sup>{{{3}}}</sup>+1|{{#ifexpr:{{{1}}}>1|{{{1}}} &times;&nbsp;}}{{{2}}}<sup>{{{3}}}</sup>-1}}
+
|3={{#ifeq:{{{1}}}|+|{{VarNum|{{{2}}}}}•2<sup>{{VarNum|{{{3}}}}}</sup>+1|{{#ifeq:{{{1}}}|±|{{VarNum|{{{2}}}}}•2<sup>{{VarNum|{{{3}}}}}</sup>±1|{{#ifeq:{{{1}}}|1||{{VarNum|{{{1}}}}}•}}{{VarNum|{{{2}}}}}<sup>{{VarNum|{{{3}}}}}</sup>-1}}}}
|4={{#ifexpr:{{{2}}}>1|{{{2}}} &times;&nbsp;}}{{{3}}}<sup>{{{4}}}</sup>+1}}</includeonly>
+
|4={{#ifeq:{{{2}}}|1||{{VarNum|{{{2}}}}}•}}{{VarNum|{{{3}}}}}<sup>{{VarNum|{{{4}}}}}</sup>{{{1}}}1}}</includeonly>

Latest revision as of 07:27, 28 September 2020

Purpose

Display numbers of the form kbn±1 in text-mode.

Usage

This template uses one to four unnamed parameters which are defined as follows:

  • Only if the first parameter is + or ±, the '+'/'±'-value is displayed, otherwise the '-'-value of the number.

Three more parameters containing numbers/variables can be given and used as follows:

  • one parameter: the n-value is given and displays as 2n±1
  • two parameters: the k- and n-value are given and display as k•2n±1
  • three parameters: the k-, b- and n-value are given and display as kbn±1

Examples

  • one parameter: {{Kbn|123}}: 2123-1
  • two parameters: {{Kbn|3|123}}: 3•2123-1
  • three parameters: {{Kbn|3|5|123}}: 3•5123-1

With '+'-sign:

  • {{Kbn|+|123}}: 2123+1
  • {{Kbn|+|13|123}}: 13•2123+1
  • {{Kbn|+|3|5|123}}: 3•5123+1

With '±'-sign:

  • {{Kbn|±|123}}: 2123±1
  • {{Kbn|±|13|123}}: 13•2123±1
  • {{Kbn|±|3|5|123}}: 3•5123±1

Others:

  • To display only 10123+1, set the k-value to '1': {{Kbn|+|1|10|123}} (or {{Kbn|1|10|123}} to get 10123-1).

Also possible:

  • {{Kbn|2<sup>{{Vn}}</sup>}}: 22n-1
  • {{Kbn|k|b|n}}: kbn-1
  • {{Kbn|+|k|b|n}}: kbn+1
  • {{Kbn|1|b|n}}: bn-1
  • {{Kbn|+|(b-1)|b|n}}: (b-1)bn+1