Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref

Author Message
mauvis

New User

Joined: 27 Jul 2007
Posts: 11
Location: india

 Posted: Wed Aug 29, 2007 12:34 am    Post subject: How we can find the prime number Can anyone tell me how we can find the prime number? i need a simple logic...i need to accept a number through the JCL and have to check through cobol for prime no... Mauvis

superk

Joined: 26 Apr 2004
Posts: 4650
Location: Raleigh, NC, USA

 Posted: Wed Aug 29, 2007 12:40 am    Post subject: Reply to: prime number A Google search led to this website which has an example program.
Balraj

New User

Joined: 16 Aug 2007
Posts: 34
Location: Bangalore

 Posted: Wed Aug 29, 2007 10:29 am    Post subject: Logic Accept A Perform varying i from 2 by 1 untill i > A Divide A by i giving c remainder D if D = 0 Not a prime stop run End-if end-perform A is a prime no. stop run.
himanshupant

New User

Joined: 21 Mar 2007
Posts: 46
Location: India

 Posted: Tue Sep 25, 2007 1:20 pm    Post subject: after thought Just an afterthought , most of the times mainframe question / queries have some underlying Business requirement which needs to be satisfied , what was the business requirement behind this... As for prime number bit , we can repeatedly divide the number ( Say x ) from 2 till x/2 and if in any of the case it divides exactly then its not a prime. We need not divide it till the number x.. This will reduce the number of iterations through loop Correct me if I am wrong
guptae

Moderator

Joined: 14 Oct 2005
Posts: 1190
Location: Bangalore,India

Posted: Tue Sep 25, 2007 1:27 pm    Post subject:

Hi himanshupant,

 Code: As for prime number bit , we can repeatedly divide the number ( Say x ) from 2 till x/2 and if in any of the case it divides exactly then its not a prime. We need not divide it till the number x.. This will reduce the number of iterations through loop

For prime number there is no need to divide till the number x/2 we can repeatedly divide the number til &#8730;x
guptae

Moderator

Joined: 14 Oct 2005
Posts: 1190
Location: Bangalore,India

 Posted: Tue Sep 25, 2007 1:28 pm    Post subject: Hi All, In my prev post i mean till square root of X
 All times are GMT + 6 Hours
 Page 1 of 1

Search our Forum:

 Topic Author Forum Replies Posted Similar Topics Find & Replace string in CA-SORT mrgnndhmk CA Products 1 Fri Mar 30, 2018 12:58 am Repeat Sequence Number Until change i... rahulabvp DFSORT/ICETOOL 6 Thu Mar 29, 2018 12:51 pm Find a string in PS file opened in br... mukkas CLIST & REXX 3 Sat Feb 24, 2018 2:15 pm add sequence number for duplicate rec... SRUTHI DRAVIDAMANI COBOL Programming 11 Thu Feb 22, 2018 5:37 pm PARSE GDG name to separate generation... Abid Hasan SYNCSORT 2 Sun Feb 11, 2018 3:40 pm

 © 2003-2017 IBM MAINFRAME Software Support Division
 Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us