<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: GCD in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/gcd/m-p/2015175#M411733</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;What's the reason for asking this question: are you going to teach for some school children?&lt;/P&gt;&lt;P&gt;Try your self to find the GREATEST COMMON DIVISIOR of three numbers.&lt;/P&gt;&lt;P&gt;Take 3 varaibles: let say a1, a2. a3.&lt;/P&gt;&lt;P&gt;Do a1 times.&lt;/P&gt;&lt;P&gt;You start dividing continuously all these three numbers .&lt;/P&gt;&lt;P&gt;when ever you get the last number which devides these three numbers, that is the GCD.&lt;/P&gt;&lt;P&gt;endddo.  &lt;/P&gt;&lt;P&gt;reward if useful&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Anji&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Wed, 14 Mar 2007 12:51:40 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2007-03-14T12:51:40Z</dc:date>
    <item>
      <title>GCD</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/gcd/m-p/2015172#M411730</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;how to write program in abap to find GCD of three numbers&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2007 12:36:24 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/gcd/m-p/2015172#M411730</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-14T12:36:24Z</dc:date>
    </item>
    <item>
      <title>Re: GCD</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/gcd/m-p/2015173#M411731</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Looks as if I will have to ask.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;What is GCD.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2007 12:44:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/gcd/m-p/2015173#M411731</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-14T12:44:55Z</dc:date>
    </item>
    <item>
      <title>Re: GCD</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/gcd/m-p/2015174#M411732</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;martin its &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;greatest common divisor&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2007 12:48:49 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/gcd/m-p/2015174#M411732</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-14T12:48:49Z</dc:date>
    </item>
    <item>
      <title>Re: GCD</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/gcd/m-p/2015175#M411733</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;What's the reason for asking this question: are you going to teach for some school children?&lt;/P&gt;&lt;P&gt;Try your self to find the GREATEST COMMON DIVISIOR of three numbers.&lt;/P&gt;&lt;P&gt;Take 3 varaibles: let say a1, a2. a3.&lt;/P&gt;&lt;P&gt;Do a1 times.&lt;/P&gt;&lt;P&gt;You start dividing continuously all these three numbers .&lt;/P&gt;&lt;P&gt;when ever you get the last number which devides these three numbers, that is the GCD.&lt;/P&gt;&lt;P&gt;endddo.  &lt;/P&gt;&lt;P&gt;reward if useful&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Anji&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2007 12:51:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/gcd/m-p/2015175#M411733</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-14T12:51:40Z</dc:date>
    </item>
    <item>
      <title>Re: GCD</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/gcd/m-p/2015176#M411734</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;*A crude way of doing GCD. Can use paramters on selection screen if reqd&lt;/P&gt;&lt;P&gt;data: n1 type i, " First Number&lt;/P&gt;&lt;P&gt;      n2 type i, " Second Number&lt;/P&gt;&lt;P&gt;      n3 type i, " Third Number&lt;/P&gt;&lt;P&gt;      n4 type i, " Find reminder for first number&lt;/P&gt;&lt;P&gt;      n5 type i, " Find reminder for Second Number&lt;/P&gt;&lt;P&gt;      n6 type i, " Find reminder for third number&lt;/P&gt;&lt;P&gt;      n7 type i, " Stores GCD &lt;/P&gt;&lt;P&gt;      n type i.  " Counter&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      n = 2.&lt;/P&gt;&lt;P&gt;      n1 = 30.&lt;/P&gt;&lt;P&gt;      n2 = 15.&lt;/P&gt;&lt;P&gt;      n3 = 45.&lt;/P&gt;&lt;P&gt;      do.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     n4 = n1 mod n." Divide by counter&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     n5 = n2 mod n.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     n6 = n3 mod n.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;*Stop if the counter is greater than any given number.&lt;/P&gt;&lt;P&gt;     if sy-index gt n1 or sy-index gt n2 or sy-index gt n3.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     exit.&lt;/P&gt;&lt;P&gt;     endif.&lt;/P&gt;&lt;P&gt;           if n4 = 0 and n5 = 0 and n6 = 0.&lt;/P&gt;&lt;P&gt;     n7 = n.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;     endif.&lt;/P&gt;&lt;P&gt;     n = n + 1.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      enddo.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;      write n7.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Wed, 14 Mar 2007 13:39:10 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/gcd/m-p/2015176#M411734</guid>
      <dc:creator>Azeemquadri</dc:creator>
      <dc:date>2007-03-14T13:39:10Z</dc:date>
    </item>
    <item>
      <title>Re: GCD</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/gcd/m-p/2015177#M411735</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi ,&lt;/P&gt;&lt;P&gt; Am not going to teach school children. Am myself learning ABAP so i want to practice some logics in ABAP so i tried for that but i cant able to get so only i asked.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Mar 2007 04:28:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/gcd/m-p/2015177#M411735</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-15T04:28:16Z</dc:date>
    </item>
    <item>
      <title>Re: GCD</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/gcd/m-p/2015178#M411736</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi , &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Execute the code .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;REPORT zex13 .


PARAMETERS : a TYPE i ,
             b TYPE i ,
             c TYPE i .

DATA : d TYPE i,
       low TYPE i.
DATA : r1 TYPE i ,
       r2 TYPE i ,
       r3 TYPE i .



* find the least of the three numbers .

IF a &amp;lt; b.
  low = a.
ELSE .
  low = b.
ENDIF.

IF c &amp;lt; low .
  low = c.
ELSE .
  low = low.
ENDIF.


*find the gcd.

WHILE ( low &amp;gt;= 1 )   .

  r1 =  a MOD low.

  r2 =  b MOD low.

  r3 =  c MOD low.

  IF r1 = 0 AND r2 = 0 AND r3 = 0.
    WRITE :/ 'Gcd of', a, b , c , 'is' , low.
    EXIT.
   
  ENDIF.
  low = low - 1.

ENDWHILE.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;Steps .

For ur query 


1. First find the least value of the given 3 numbers .

2. Divide the 3 numbers with this  low  value .

3.See the GCD cannot be greater than the low value at most it can be  equal to or less than the low value .    
       
4 . GCD of the 3 numbers is when u have a zero reminder for all the numbers .

      We will search this condition keeping in loop by approaching the Low value in the reverse till we get the condition true i.e R1 = 0 ,R2 = 0, R3 = 0.

5. Once a hit then exit out of the loop .
    that is ur gcd .

6. When this condition also is failing then GCD can be only 1 for the exception .


I hope this will solve ur query .&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Still you can enhance the logic to the above code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Revert back for further queries .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Vijay. &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;:):)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Mar 2007 06:53:18 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/gcd/m-p/2015178#M411736</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-15T06:53:18Z</dc:date>
    </item>
    <item>
      <title>Re: GCD</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/gcd/m-p/2015179#M411737</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi vijay,&lt;/P&gt;&lt;P&gt;  Thanks its working fine.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Mar 2007 08:20:38 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/gcd/m-p/2015179#M411737</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-15T08:20:38Z</dc:date>
    </item>
    <item>
      <title>Re: GCD</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/gcd/m-p/2015180#M411738</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hi, thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 15 Mar 2007 08:27:25 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/gcd/m-p/2015180#M411738</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2007-03-15T08:27:25Z</dc:date>
    </item>
  </channel>
</rss>

