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

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

User avatar
Stefan Kottwitz
Site Admin
Posts: 10348
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