Text FormattingCALCULATOR PACKAGE, CHECK A NUMBER

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
phanttam
Posts: 2
Joined: Wed Feb 03, 2016 10:55 pm

CALCULATOR PACKAGE, CHECK A NUMBER

Post by phanttam »

I have a problem about CALCULATOR PACKAGE, I need check #1 is a number or not, could I use contitional command?
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!

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

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

Post by Stefan Kottwitz »

Welcome to the forum!

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
LaTeX.org admin
phanttam
Posts: 2
Joined: Wed Feb 03, 2016 10:55 pm

CALCULATOR PACKAGE, CHECK A NUMBER

Post by phanttam »

Thanks Stefan_K, could you introduce me another package?
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}
User avatar
Johannes_B
Site Moderator
Posts: 4182
Joined: Thu Nov 01, 2012 4:08 pm

CALCULATOR PACKAGE, CHECK A NUMBER

Post by Johannes_B »

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
The smart way: Calm down and take a deep breath, read posts and provided links attentively, try to understand and ask if necessary.
Post Reply