Skip to content

Instantly share code, notes, and snippets.

View stephenykp's full-sized avatar

Stepheny Perez stephenykp

View GitHub Profile
@stephenykp
stephenykp / group.c
Created November 3, 2017 21:20
Finds various things about a group of order p, like Zp*, generators, and info on those generators like whether they generate a cyclic subgroup, and whether that subgroup will tally correctly with our 'residues modulo p' formula
//
// Extremely verbose at the moment...
//
//
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int p; // Group of order p
int * ZpStar; // Set of integers coprime with p
@stephenykp
stephenykp / powermod.c
Last active November 14, 2017 04:23
Power -> mod [a^b mod c] -- possibly large numbers
//a^b mod c with a possibly huge b
int power_mod(int a, int b, int c)
{
if (b * log(a) > 9) //9 digits is my max, could change this to be dynamic for your compiler.
{
int b1 = b/2;
int b2 = b/2;
if (!(b % 2)) b2++;