Skip to content

Instantly share code, notes, and snippets.

@suut
Created February 16, 2014 14:58
Show Gist options
  • Select an option

  • Save suut/9035580 to your computer and use it in GitHub Desktop.

Select an option

Save suut/9035580 to your computer and use it in GitHub Desktop.
#include "Jacobi.hpp"
void Jacobi::fac2(uintmax_t n, uintmax_t &a, uintmax_t &b)
{
uintmax_t ret_a = 0;
uintmax_t ret_b = n;
while((ret_b&1) == 0)
{
ret_b = ret_b >> 1;
ret_a++;
}
a = ret_a;
b = ret_b;
}
#include <iostream>
class Jacobi
{
public:
static void fac2(uintmax_t n, uintmax_t &a, uintmax_t &b);
};
#include <iostream>
#include "Jacobi.hpp"
using namespace std;
int main(int argc, char **argv)
{
uintmax_t ret_a;
uintmax_t ret_b;
uintmax_t n = 1872;
Jacobi::fac2(n, ret_a, ret_b);
cout << "2^" << ret_a << " * " << ret_b << endl;
return(0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment