Search
 
SCRIPT & CODE EXAMPLE
 

C

Greatest common divisor iterative

fn gcd(mut m: i32, mut n: i32) -> i32 {
   while m != 0 {
       let old_m = m;
       m = n % m;
       n = old_m;
   }
   n.abs()
}

fn main() {
    println!("Greatest Common Divisor = {} ",gcd(115, 230));
}
Comment

Greatest common divisor iterative

#include<stdio.h>

int gcd_iter(int u, int v) {
  if (u < 0) u = -u;
  if (v < 0) v = -v;
  if (v) while ((u %= v) && (v %= u));
  return (u + v);
}

int main() {
    printf("Greatest Common Divisor = %i", gcd_iter(115, 230));
}
Comment

PREVIOUS NEXT
Code Example
C :: C Program to Maintain an Inventory of items in Online Store 
C :: error: ‘_Atomic’ does not name a type 
C :: C if...else Statement 
C :: remove every appearance of char without malloc in c 
C :: arma 3 key pressed 
C :: command line arguments to copy paste in c 
C :: c program to take array input from user 
C :: pebble scripting Boolean expression 
C :: Uri/beecrowd problem no - 1099 solution in C 
C :: Reverse every Word of given String 
C :: how to initiate pointer array with null in c 
C :: fina students name by using html backend database 
C :: how we can strore a nested structure values in arrays 
C :: sue murry 
C :: nc,manc 
C :: Calculate the area of a circle and modify the same program to calculate the volume of a cylinder given its radius and height. 
C :: How to get the number of characters in a string without using strlen function 
C :: online c compiler with mpi 
C :: sdl_rect 
C :: nosql injection 
C :: hello world in c language 
C :: c triangle check if triangle is 90 degrees 
Dart :: TextStyle underline flutter 
Dart :: text fieldform color flutter 
Dart :: Keyboard Pushes Text Fields off screen flutter 
Dart :: waiting for another flutter command to release the startup lock 
Dart :: flutter chip label 
Dart :: flutter linear progress indicator height 
Dart :: underline text flutter color 
Dart :: dart square root 
ADD CONTENT
Topic
Content
Source link
Name
2+3 =