Difference between revisions of "Template:IsEven"

From PlantUse English
Jump to: navigation, search
(Created page with "<includeonly>{{#vardefine: data|{{{1}}}}}{{#vardefine: dec|{{#expr:{{#var:data}}/2}} }}{{#vardefine:trunk|{{#expr:trunc{{#var:dec}}}} }}{{#ifeq:{{#var:dec}}|{{#var:trunk}}|true|}...")
 
Line 7: Line 7:
 
return true if even, false if not  
 
return true if even, false if not  
 
=== Exemple ===
 
=== Exemple ===
<nowiki>{{IsEven|1}}</nowiki> returns {{EstPair|1}}
+
<nowiki>{{IsEven|1}}</nowiki> returns {{IsEven|1}}
<nowiki>{{IsEven|21}}</nowiki> returns {{EstPair|21}}
+
<nowiki>{{IsEven|21}}</nowiki> returns {{IsEven|21}}
<nowiki>{{IsEven|42}}</nowiki> returns {{EstPair|42}}
+
<nowiki>{{IsEven|42}}</nowiki> returns {{IsEven|42}}
 
[[category:Template]]
 
[[category:Template]]
 
</noinclude>
 
</noinclude>

Revision as of 09:46, 11 May 2011


Template to test if a number is even or not

Parameters :

the number to test return true if even, false if not

Exemple

{{IsEven|1}} returns {{IsEven|21}} returns {{IsEven|42}} returns true