Detecting odd and even numbers

How can I now when an integer is an even or an odd number?

How can I now when an integer is an even or an odd number?Either of these will work:
if (i % 2 == 0)
    // even
else
    // odd
if ((i & 1) == 0)
    // even
else
    // odd

Similar Messages

  • Selective combining between files with odd and even numbers of pages

    Hi all! First of all, i hope this is the right forum for my question. It has been asked before, but not fully answered. My problem is combining multiple pdfs with adding a blank page only to the ones that contain odd numbers of pages, the ones with even numbers should be left alone. I need a fast and automatic way of doing this so i can save huge amounts of time when faced with massive numbers of files. If this simply cannot be done, is there a way of sorting all the files so that, from the whole group, only the ones with odd numbers of pages go to a specified folder? Like this isnt enough i have the same problem when converting, lest say, multiple word files into 1 pdf file using pdf factory.
    Thanx in advance! also, any other way to go arround this problem is most welcome!
    Cheers!

    It would require knowledge of some JavaScript to determine if a particular page was landscape and if so, to rotate it. You could try asking in the JavaScript forum.

  • Function detect odd and even number

    Do you know a function which can detect if a number is an odd number or other.

    if ( number%2 == 1)
    But a method for this? Really doubt that..
    Do you know a function which can detect if a number is
    an odd number or other.

  • Odd and Even Headers in Pages 5

    I think this has been asked before, but is it possible to making different odd and even-paged headers in Pages 5? I can't figure it out.

    You can take this to be the answer for most things Pages 5…
    … No!
    Use Pages '09 instead.
    Peter

  • Different margin for odd and even pages

    Hi there,
    I am writing a book which will be printed in 2 sided paper. Therefor I will need different margin (left and right) for the odd and even pages.
    How is it possible in Pages? I am using Pages 5.2 (1860).
    Thank you.
    Sebastian.

    Indesign & Xpress are professional DTP applications. They can layout pages in any order you can imagine with custom margins. They are also complex to learn & expensive in comparison to Pages.
    There is a trial of Indesign IIRC…
    https://www.adobe.com/uk/products/indesign.html
    Quark also has a trial too…
    http://www.quark.com
    I expect there may be cheaper 'layout' software that is capable of arranging facing pages correctly (possibly from a single pages PDF export from Pages), but I just avoid apps like Pages if I need a finer level of output control.

  • Printing odd and even pages separately (manual duplex)

    Hi
    I searched the forum and found some similar problems regarding Adobe Reader 8.1.2 : Adobe Reader 8.1.2 doesn't print odd and even pages correctly
    This was posted more than a year ago. A few days ago I encountered the same problem with Adobe Acrobat 8.1.2. I suspected that it could be beacause of outdated software. I then applied incremental patches up to 8.1.5. But the problem still persists.

    The link was about Reader, but I tried it with AA8.1.5 on a 3 page document and did indeed find the same problem. The 1st page printed out, but the 3rd page was missing when printing the odd pages. When printing the even pages, the 2nd page printed out 2 times. The 3rd page never showed up. I think this is what you are talking about. Wonder if they fixed it in AA9?

  • Is it possible to have different margin settings for odd and even pages?

    Hi guys.
    I am formatting a book I want to get printed and it would be very helpful to have different margin settings on the odd and even pages so the text won't fall too close to the gutter (as happened in the proof copy I ordered!).
    It's possible to do this on Word, but I can't seem to do it on Pages? Am I missing something?
    Any help would be greatly appreciated. Thank you

    Thanks Peter. I upgraded to Pages 5 a while back. I guess my next question is.....is there any way I can downgrade to Pages 09...anywhere I can still download it from?
    Seems a bit of a backward step, but needs must

  • Odd and even rotating pages by file name

    Hi all,
    Hoping someone can help me trouble shoot my script below.
    The aim is to determined if the last two digits of the file name are odd or even and then rotate the file accordingly.
    I have been able to get the page rotation work by it's self but it seems to do nothing at all when trying to get the last two digits of the filename and use them as the variable "pgNum".
    Files will be named using the following convention....
    aa-02-02.pdf
    Thank you in advance for you help.
    =======================================================================================
    var re = /.*\/|\.pdf$/ig;
    var filename = this.path.replace(re,"");;
    var pgNum = filename.substring(-2);
    try {
        if(pgNum % 2) {
            var crtpagerotate = this.getPageRotation({nPage:i});
            this.setPageRotations({nStart: i, nEnd: i, nRotate:(270+crtpagerotate)%360});
        else {
            var crtpagerotate = this.getPageRotation({nPage:i});
            this.setPageRotations({nStart: i, nEnd: i, nRotate:(90+crtpagerotate)%360});
    catch (e)
        console.println("Batch Aborted: " + e )

    Try this:
    var re = /\.pdf$/i;
    var filename = this.documentFilename.replace(re, "");
    var pgNum = +filename.slice(-2);

  • Odds and evens

    Hi,
    How can i determine when a number is odd or even?.
    Rgds,
    Jose

    hi,
    Just divide by 2, and check the remainder.
    report ztest.
    data:
          rem type p decimals 2,
          val type i value 657.
    rem = ( val mod 2 ).
    if rem = 0.
      write:/ 'Even'.
    else.
      write:/ 'Odd'.
    endif.
    Hope this helps !!!
    Cheers
    Alfred

  • Odd and even years with Time Windows?

    Hi All,
    Does anybody know how to implement a time window for even years / ode years?
    For example, a script A that needs to be executed every 1st January of even years and a script B that needs to be executed every 1st January of odd years.
    At last, it possible to :
    - specify hard coded dates in TW for these scripts,
    - use particular pre conditions (which script from A or B has to be executed) with a common yearly TW
    but better solutions are welcome
    Thanks a lot.
    Regards,
    Yi Jiang

    Hi Yi,
    If you need this for only one case, I'd go for the one-off setup of specific dates.
    If you have multiple cases, a simple way to achieve your goal is the following set of time windows:
    - TW_EVEN_YEARS: from 1-1-2010 to 31-12-2010, 1-1-2012 to 31-12-2012, 1-1-2014 to 31-12-2014, ...
    - TW_ODD_YEARS:  from 1-1-2009 to 31-12-2009, 1-1-2011 to 31-12-2011, 1-1-2013 to 31-12-2013, ...
    and then
    - TW_DAY1_EVEN_YEARS: day 1 enabled during TW_EVEN_YEARS
    - TW_DAY1_ODD_YEARS: day 1 enabled during TW_ODD_YEARS
    - TW_LAST_FRIDAY_EVEN_YEARS: last friday enabled during TW_EVEN_YEARS
    - TW_LAST_FRIDAY_ODD_YEARS: last friday enabled during TW_ODD_YEARS
    etc.
    This way, you do not need to specify the dates for each case, only once.
    Regards,
    Anton.

  • Odd and even pages

    Hello all, Need some help on the xdp that I am working on.
    This xdp has 1 Page Set- set to Print on Both Sides.
    The first master page is the Odd Pages (Front pages).
    The second master page is the Even Pages (Back pages).
    There isn't much logic on the Even Pages as it is only static information.
    The content on the Odd (Front) pages flow and page number grow depending on the XML data I feed into it. I have explicitly set the content to flow through the content are of the Odd (Front) page only. Problem is, when the data breaks, it still puts a record or two on the content area of the Even (Back) page.
    Also, I was hoping that whenever there is an Odd (Front) page, I would assume that it would always have an Even (Back) page, but that is not the case. Sometimes the pages end out on the Odd Page.
    I would like to share the xdp along with the xml that I am working on to this posting. Is there a way to upload this information. Thanks in advance.

    Hi,
    The trouble is that when you have repeating objects they will continue in the container as new instances are added. When the page overflows, Acrobat/Reader is creating a new instance of the page, in which the new instances of the repeating object can be rendered.
    I had an example earlier that "jumped" a section, but in reality what it was doing was when the first page was full, it started to use a similar repeating instance on page3. Here it is, but you will need to have a close look at the script, as this was not annotated: https://acrobat.com/#d=0-YvJ8UcVW7Pyc4hhg3RmQ. It is a bit of a rough workaround, based on the height of the subform (see the click event of the add button on page1).
    You might also be able to get a conditional page break to work if the height of the rows was always the same.
    Hope that helps,
    Niall

  • Flipped even-numbered pages when printing double-sided from Preview

    My HP 2015dn printer has the ability to print double-sided. Yet I'm finding that when printing from Preview, the even-numbered pages are flipped 180 degrees. I can see the rationale for this, but I'd like to disable it and have the orientation the same for both odd- and even-numbered pages. There is a setting in the print dialog to "automatically rotate each page," but that is not what I want.
    Any ideas?

    That fixed it. The pdfs were rotated so that they would appear in landscape orientation on my screen (they're originally photocopies of side-by-side book pages). Well, now I understand the difference between short-edge and long-edge binding! Thanks for your help.

  • Using Acrobat 9.5.5, I scanned a catalog in several segments, to merge later. How do I reverse the order of pages of the back side (odd) pages, and can I renumber each set as even numbers only and odd numbers only?

    I scanned a catalog for my archive - double sided pages of course.
    It was easy enough to scan the front pages first (odd numbers, 1-3-5) , in several sets of 30 pages, therefore several separate pdfs.
    Then I scanned the back side (even numbers 2-4-6) pages but in their natural reverse order, rather than manually reordering all 300 pages.
    Now I need to reorder the even pages which are naturally in reverse page number order (300-298-296...)
    and I need to renumber all of the pages as only odd or even numbers - set 1: pages 1-3-5-7... Set 2: 2-4-6-8...
    Then I can merge everything into one pdf.
    How can I reverse the page order?
    How can I renumber pages as only even or only odd numbers?
    Anyone have these solutions?  I don't use much of acrobats features, but it seems to be a pretty basic demand to be included. I can't find any clue in the software menus or online help.

    You can do such ordering with JavaScript. There is a recent post with a JavaScript for dealing with another aspect of page order that might provide what you want. You will have to search the forum for the post that was about 2 or 3 weeks ago as I recall.

  • How to specify Master page depending on odd or even first page

    We've set up our books to delete empty pages and so that we have chapters starting on both odd and even pages. Also, the first pages of our chapters are formatted differently than the rest of the Left and Right Master pages. We would like to have two Master pages for the first page of the chapter, one for odd pages and the other for even, so that we can offset the margins, leaving a larger margin on the side towards the binding.
    My question is how do I set up the book so that when it generates, if the chapter starts on an odd page, it automatically applies the Master page for odd first pages and when the first page is even, it applies the Master page for even first pages?
    We have FramMaker 8 and are running it on Windows XP Professional.
    Thanks,
    Tim

    Assuming that you want this to happen automagically, I'd use the system default Right and Left Master pages as your chapter opener pages because Frame will apply those automatically depending on how the pages and chapters fall in the book. Then set up the internal chapter pages with whatever other structure you're using and apply those internal masters to the normal content that as you go.
    If you can't do that for some reason, I would look at doing it with a FrameScript that goes through the book and applies the alternating pages as a final production step.
    You could set up the first tag in the chapter to call a specific master page, but that would be manual and could quickly go south if any chapters ahead of a given chapter change the pagination. It would have to be manual because a given tag can only call one master page -- there isn't a way to apply logic to call one or the other depending on the situation.

  • How do I "Print Booklet" with just odd pages and even pages for duplexing . . options disabled

    I have InDesign CS5.5 on a Windows 7 64-bit machine hooked to a Xerox 7750 printer.  I have created a 8.5x11 portrait document and trying to create a booklet on 12x18 sheets.
    I need to print duplex manually and so I need to print just the odd spreads and then the even spreads.
    I have printed to Adobe PDF and printed from my created PDF file and have it working, but I want to know why InDesign won't let me do it.  When I click "File > Print Booklet > Print Settings" then it shows the Print Dialog box with the Pages section, which includes the Sequence that normally would allow me to do Odd Pages or Even Pages, but it is disabled.  Why?  I can define Print Presets and I can choose Odd Pages, but when I choose that in the Preset box it does not show anything, everything is still disabled.
    Anybody have any idea of why it is disabled?  Is it my printer driver?

    I too was very frustrated after upgrading to indesign cs5.5 and the latest LION OS on my new MAC.  I missed the odd/even page selection in the print dialog box within Indesign.  I tried about everything and found little of value in various forums.  But I did find a workable solution that makes since in terms of Apple's OS.
    My objective is to "impose" my document and also end up with a file that I can just print again and again without "ripping" in the InDesign Print Booklet Dialog.
    Here is the quick version of what to do.  I am not including every little step with pictures. =)  (I can if there is interest.)
    1. create your document
    2. Print Booklet
    3. At the first dialog box, just ignore the printer in print preset (you will come back to this) and go to the 2-up perfect bound option and select 16 page signatures.  This will impose 2-up on 4 physical pieces of paper printed both sides.  So 16 of your document pages printed duplex on 4 physical sheets of paper.  It would be nice to then just select the printer and scaling, etc. and the option to print even pages, flip over and then print odd pages but that ain't an option.  If you have different needs, do the math and input the correct numbers before proceeding
    4. Click on Print Settings  to pull up a second dialog box.
    5. Select for Printer PostScript File (not your printer)  Also select for PPD your printer or Adobe PDF 9 if you have that installed.  Don't obsess on this just pick your Printer for the PPD.
    6. Select 1 copy and All Pages while in the General Tab
    7. Select the Setup Tab Here is where you put in the actual physical paper size that you are going to print your document on. Don't scale to fit.  You must do this.  If you feel the need, check out all the tabs and options but for now, you are just trying to get an output file.  You probably do want to select CENTER for page position in this same setup tab.
    8. Hit OK whcih will return you to the original dialog.  Check when you return to be sure that at the top Printer is populated with PostScript File.  Click on Print and give the thing a name and a location to save at the resulting dialog.
    Breathe as you are almost home.  You have sucessfully created a file that can be called up again and again without opening InDesign. (albeit, a postscript file but not a problem)
    Now,
    1. Double click on this new file (it will have a .ps extention) or just open it in your PREVIEW (apple supplied utility)   Preview is where you accomplish the even and odd page objective.
    2. Preview will show you a short progress dialog while it rips this postscript file into a PDF.
    3. Click on PRINT
    4. Select your printer,page range, select the Paper Size (again not document size  but  the size sheet that you are printing the 2-up , imposed (booklet) document on. If not in the selection dialog, then use the custom option to create it (custom paper size) and give it a name.
    5. Click on SCALE and insert 100% in place of the weird number that it will insert for you.  You will then see your document correctly displayed in the sidebar preview window.
    6.  OK, now what you have been waiting for. Click on the box that says Preview (the active window) and select Paper Handling from the drop-down and select from Pages to Print the coveted odd or even page selection.  You can also do other things that should have been back at the InDesign print dialog but are now gone.  Explore. Enjoy.
    7.  You will have to work out your own work flow about reverse or no reverse order and how to flip, etc. But you will be working with something predictable at this point.
    8.  Since this has been ripped into a PDF , you might as well Click on the PDF button and click on save as a PDF at this point to save that postscript to PDF rip.   Also print using PREVIEW for the newly created PDF file next time as you will not have to learn a bunch of new dialogs and be frustrated all over again.
    I am now back in business printing the book blocks for my handbound journals.

Maybe you are looking for

  • Question about network statement in OSPF and BGP

    The network statements in OSPF and BGP can be used to advertise networks. But I'm not clear under what circumstances would make more sense to use network statements to advertise a network than by using other methods to have the network learned by oth

  • Problems printing graphics from iPages

    My printer (currently HP3800) doesn't like to print certain graphics or images from iPages, which is a problem because I create brochures within a small office. Can anyone recommend a printer that you have not had trouble printing from iPages that is

  • Please Review my CLD Sample Exam

    I am going to take the CLD in a month or so, so I figured I would work on some of the exams and post it up here for your advice. I started with the Car Wash exam, and will do the other ones as well. Thank you. Any and all comments are welcome. Kenny

  • HT4623 why won't my i phone back up? I plug in on itunes and then a message appears saying there was an error.

    why won't my i phone back up? I plug in on itunes and then a message appears saying there was an error.what is wrong with it?

  • Problem running shell command

    hi i am just trying to run a simple msdos command public class TestImage{     public static void main(String args[]){      try{          Process p=Runtime.getRuntime().exec("echo");      catch(IOException e){          System.out.println(e); }and i ge