numero par o impar?

numero par o impar?

Postby goosfancito » Mon Apr 25, 2016 8:01 am

Hola.
Existe alguan funcion interna que te diga si es impar o par un numero?
(para no codificar una funcion)

gracias.
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm

Re: numero par o impar?

Postby AngelSalom » Mon Apr 25, 2016 9:25 am

Esto te puede valer :
Code: Select all  Expand view
If Int(nNumero/2)=nNumero/2


Para probar :

Code: Select all  Expand view
#include "fivewin.ch"

Function Main()
Local nNumero:=24

If Int(nNumero/2)=nNumero/2
  msginfo ('par')
else
 msginfo ('impar')
endif
Return (nil)
Angel Salom
Visionwin Software - https://www.visionwin.com
------------------------------------------------------------
fwh 19.05 - harbour 3.2 - bcc 7.4
User avatar
AngelSalom
 
Posts: 727
Joined: Fri Oct 07, 2005 7:38 am
Location: Benicarló (Castellón ) - España

Re: numero par o impar?

Postby Biel EA6DD » Mon Apr 25, 2016 9:44 am

Code: Select all  Expand view
FUNCTION IsPar(num);RETURN IIF(num%2=0,.T.,.F.)
Saludos desde Mallorca
Biel Maimó
http://bielsys.blogspot.com/
User avatar
Biel EA6DD
 
Posts: 682
Joined: Tue Feb 14, 2006 9:48 am
Location: Mallorca

Re: numero par o impar?

Postby goosfancito » Mon Apr 25, 2016 11:22 am

gracias a ambos dos!

pense que habia una funcion interna, ya estoy usando ese metodo.
FWH 21.02
Harbour 3.2.0dev (r2104281802)
Copyright (c) 1999-2021, https://harbour.github.io/
User avatar
goosfancito
 
Posts: 1954
Joined: Fri Oct 07, 2005 7:08 pm


Return to FiveWin para Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot], Horizon and 92 guests