Skip to content

Instantly share code, notes, and snippets.

@mvanorder
mvanorder / sqrt.c
Created August 16, 2018 16:55
A small program that finds the perfect square root that is closest to but not over the root of the provided integer.
#include <stdio.h>
#include <stdlib.h>
void main(int argc, char **argv) {
unsigned int n; // Input number
unsigned int n2; // Duplicate of input number to be worked with
int s = 0; // Shift counter
unsigned int a = 0; // Answer
unsigned int c = 0; // Carry number
n = atoi(argv[1]); // Read the first parameter provided and convert it to int
from math import sqrt
# 2 constants: the square root of 2, and the raduis of the circle we're
# drawing.
ROOT_2 = sqrt(2)
RADIUS = float(1000000000)
# 2 variables: current x position, and the area of the circle being
# calculated.
x = RADIUS