Text Formatting ⇒ CALCULATOR PACKAGE, CHECK A NUMBER
CALCULATOR PACKAGE, CHECK A NUMBER
ex:
def \CHECK#1{
% if #1 a number
\if...?
#1 is a number
\else
#1 is not a number
\fi
}
\CHECK{3}
CHECK{n}
Thanks all!
Learn LaTeX easily with newest books:
The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis
The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more
LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis
- Stefan Kottwitz
- Site Admin
- Posts: 10348
- Joined: Mon Mar 10, 2008 9:44 pm
Re: CALCULATOR PACKAGE, CHECK A NUMBER
What do you mean by "CALCULATOR PACKAGE"? What is this?
And what exactly do yo try to achieve? Maybe we can help doing it using another package as well.
Stefan
CALCULATOR PACKAGE, CHECK A NUMBER
I need if #1 = n
\sum\limits_{k=0}^{n}2^k=1+2+2^2+\ldots+2^{n-1}+2^n
else
\sum\limits_{k=0}^{2016}2^k=1+2+2^2+\ldots+2^{2015}+2^2016
I can
Code: Select all
\def \SUM#1{
% check #1 is a number or not, if #1 is a number
$\sum\limits_{k=0}^{#1}2^k=1+2+2^2+\ldots+2^{\SUBTRACT{#1}{1}{\sol}\sol}+2^{#1}$
\else
$\sum\limits_{k=0}^{n}2^k=1+2+2^2+\ldots+2^{n-1}+2^n$
\fi
}
\SUM{n}
\SUM{2016}
- Johannes_B
- Site Moderator
- Posts: 4182
- Joined: Thu Nov 01, 2012 4:08 pm
CALCULATOR PACKAGE, CHECK A NUMBER
Code: Select all
\def \SUM#1{
$$\sum\limits_{k=0}^{#1}2^k=1+2+2^2+\ldots+2^{#1-1}+2^{#1}$$
}
\SUM{n}
\SUM{2016}
\vfill
\eject
\bye