Skip to content

Instantly share code, notes, and snippets.

@RicardoLara
Created November 18, 2016 05:11
Show Gist options
  • Select an option

  • Save RicardoLara/ffab3b4627abb079e271ca0e067e01e5 to your computer and use it in GitHub Desktop.

Select an option

Save RicardoLara/ffab3b4627abb079e271ca0e067e01e5 to your computer and use it in GitHub Desktop.
Varinia - Producto de nums con DV
//#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
using namespace std;
//Funcion recursiva, mando dos longs para partir el segundo
long long mult(long long A, long long B){
long X; //Variable auxiliar
if(B == 1) return A; // Caso Base
//Si no, Parto y repito
X = B/2 + B%2;
return mult(A , B/2) + mult(A , X);
}
int main(){
long long a,b;
cout << "Primer numero pls: "; cin >> a;
cout << "Segundo numero pls: "; cin >> b;
//Llamada a la funcion y gg
cout << mult(a,b) << endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment