pretty new to programming in assembly but my assignment is to write a GCD program but my program works sometimes and sometimes it doesn't work. if i put the smaller number first then the larger number i don't get the correct GCD but if i do the opposite i get the right answer example: if i enter 209 then 2585 it says the GCD is 209, which is incorrect but, if i enter 2585 then 209 it says the GCD is 11 which is correct looking for some guidance on to why my program is working one way and not … |
+0 forum
0 | ||

[CODE]#include<stdio.h> int main() { int a,b,c; (printf("\nEnter 2 no.s"))?(scanf("%d%d",&a,&b))?(c=(a>b)?a:b):0:0; while(c>=1) {if(a%c==0 && b%c==0) {printf("\nGCD:%d",c);return 0;} c--; } }[/CODE] |
+0 forum
3 | ||

hey guys I'm a newb to this C++ programming and I need help. I've made a non-recursive GCD C++ code, but i was having problems with the algorithm. Can someone help please? [ICODE]import java.util.Scanner; public class GCD { public static int GCD; public static int div; public static int remainder = 1; public static void main(String [] args) { int num2; Scanner keyboard = new Scanner(System.in); do{ //Prompting for first number System.out.println("Enter the first number: "); int num1 = keyboard.nextInt(); //Exit if(num1 <= 0) { System.exit(0); }//Ending of if //Prompting for second number System.out.println("Enter the second number: "); num2 = … |
+0 forum
3 | ||

Hello, I am trying to write a algoritm that calculates the second largest divisor of a number. But i have absolutely no idea what calculations are required for this. [CODE] for (ulong i = 1; i < Number; i++) { Number = .....? }[/CODE] Already know the largest common diviser of 2 numbers, but i cannot find anything considering the second largest divisor of a number. Kind regards. |
+0 forum
10 | ||

[CODE]please help me in doing my project in one of my subject in college. it is all about getting the GCD of fractions... can anyone tell me the logic or the formula for getting it? tnxx in advance[/CODE] |
+0 forum
4 | ||

please help know how to get the GCD of fractions... i'm stuck in program because of this... any suggestions will do. tnx |
+0 forum
1 | ||

The two numbers are accepted as Commamnd line arguements and GCD of those numbers are found using a recursive method. |
+0 forum
4 | ||

Hello, I have this program that simplifies a fraction by calculating the greatest common divisor. So the fraction 8/4 (largest common divisor = 4) 8/4 4/4 => result would be 2/1 (fraction simplified) My problem is my method calculated this greatest common divisor. But now that value has to be divided trough the nominator and denominator of the fraction (wich are a and b in my example). But i cannot seem to get that dividing to work. (will i need to make a new method or simply in this one...) Also calling up that method (another small class below the … |
+0 forum
7 | ||

Most of the time there are many ways to implement an algorithm. Here are two ways to implement the greatest common divisor algoritm, one of the oldest algorithms ever. |
+0 forum
0 |

The End.