From f30b409bcf0fa18b0d3cac3d6130717cbb331651 Mon Sep 17 00:00:00 2001 From: newt Date: Wed, 9 Oct 2024 18:02:29 +0100 Subject: [PATCH] SQUARE ROOTS --- .gitignore | 4 ++- ahk/gif keyboard.ahk | 26 +++++++++++++++++++ python/calculators/sqrt.py | 7 +++++ .../babylonian square root.java | 18 +++++++++++++ .../babylonian square root.py | 7 +++++ 5 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 ahk/gif keyboard.ahk create mode 100644 python/calculators/sqrt.py create mode 100644 royal institute computer science masterclasses/from ancient babylon to quantum computing/babylonian square root.java create mode 100644 royal institute computer science masterclasses/from ancient babylon to quantum computing/babylonian square root.py diff --git a/.gitignore b/.gitignore index 6b75623..fec3d08 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,4 @@ .idea -venv \ No newline at end of file +venv +ahk/emoji.ahk +catalogue.py diff --git a/ahk/gif keyboard.ahk b/ahk/gif keyboard.ahk new file mode 100644 index 0000000..fe1dd33 --- /dev/null +++ b/ahk/gif keyboard.ahk @@ -0,0 +1,26 @@ +:*:a::https://tenor.com/view/a-dancing-dancing-a-pesing-gif-18704788 +:*:b::https://tenor.com/view/letter-b-dancing-gif-9063746 +:*:c::https://tenor.com/view/letter-c-dancing-gif-9063747 +:*:d::https://tenor.com/view/letter-d-dancing-gif-9063748 +:*:e::https://tenor.com/view/letter-e-gif-9063749 +:*:f::https://tenor.com/view/letter-f-gif-9063750 +:*:g::https://tenor.com/view/g-letter-dance-cartoon-gif-13894794 +:*:h::https://tenor.com/view/letter-h-gif-9063752 +:*:i::https://tenor.com/view/letter-i-gif-9063753 +:*:j::https://tenor.com/view/letter-j-dance-gif-9063754 +:*:k::https://tenor.com/view/letter-k-gif-9063755 +:*:l::https://tenor.com/view/red-alphabet-letter-dancing-letter-l-cartoons-gif-12084376 +:*:m::https://tenor.com/view/letter-m-dance-happy-gif-9063757 +:*:n::https://tenor.com/view/letter-n-gif-9063758 +:*:o::https://tenor.com/view/letter-o-gif-9063759 +:*:p::https://tenor.com/view/letter-p-gif-9063760 +:*:q::https://tenor.com/view/letter-q-gif-9063761 +:*:r::https://tenor.com/view/letter-r-gif-9063762 +:*:s::https://tenor.com/view/letter-s-gif-9063763 +:*:t::https://tenor.com/view/letter-t-gif-9063764 +:*:u::https://tenor.com/view/letter-u-gif-9063765 +:*:v::https://tenor.com/view/letter-v-gif-9063766 +:*:w::https://tenor.com/view/letter-w-gif-9063767 +:*:x::https://tenor.com/view/letter-x-gif-9063768 +:*:y::https://tenor.com/view/letter-y-gif-9063769 +:*:z::https://tenor.com/view/letter-z-gif-9063770 \ No newline at end of file diff --git a/python/calculators/sqrt.py b/python/calculators/sqrt.py new file mode 100644 index 0000000..4beaa6d --- /dev/null +++ b/python/calculators/sqrt.py @@ -0,0 +1,7 @@ +def sqrt(x): + a = 2 + while abs((a - (x / a))) > 1: + a = (a + (x / a)) / 2 + return a // 1 + +print(sqrt(81)) diff --git a/royal institute computer science masterclasses/from ancient babylon to quantum computing/babylonian square root.java b/royal institute computer science masterclasses/from ancient babylon to quantum computing/babylonian square root.java new file mode 100644 index 0000000..27c9557 --- /dev/null +++ b/royal institute computer science masterclasses/from ancient babylon to quantum computing/babylonian square root.java @@ -0,0 +1,18 @@ +import java.util.Scanner; + +public class Babylonian +{ + public static void main(String [] args) + { + Scanner input = new Scanner(System.in); + long x = input.nextLong(); + double a = 2; + + while (Math.abs(a - (x / a)) > 1) + { + a = (a + (x / a)) / 2; + } + + System.out.println(a); + } +} diff --git a/royal institute computer science masterclasses/from ancient babylon to quantum computing/babylonian square root.py b/royal institute computer science masterclasses/from ancient babylon to quantum computing/babylonian square root.py new file mode 100644 index 0000000..63843cc --- /dev/null +++ b/royal institute computer science masterclasses/from ancient babylon to quantum computing/babylonian square root.py @@ -0,0 +1,7 @@ +x = float(input('Please input the number to calculate the square root of! ')) +a = 2 + +while abs((a - (x / a))) > 1: + a = (a + (x / a)) / 2 + +print(a)