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!
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
- Stefan Kottwitz
- Site Admin
- Posts: 10335
- 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