From 51a12f0a7c93d34aaf585f3c32f29149acfda749 Mon Sep 17 00:00:00 2001 From: SADIK KUZU Date: Sun, 7 Oct 2018 16:13:37 +0300 Subject: [PATCH] github.com/sadikkuzu --- README.md | 7 +++++++ code/sadikkuzu.py | 23 +++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 code/sadikkuzu.py diff --git a/README.md b/README.md index 8e643b9..7ae609c 100644 --- a/README.md +++ b/README.md @@ -1305,6 +1305,13 @@ Please note that this project is released with a [Code of Conduct](CODE_OF_CONDU # S +### Sadik Kuzu +- I am a Senior Software Specialist with a demonstrated history of working in the insurance industry. +- Skilled in Agile Methodologies (Scrum&Kanban), Test Automation, PL/SQL, Python, and MongoDB. +- [![github-alt][github-img]](https://github.com/sadikkuzu) + [![twitter-alt][twitter-img]](https://twitter.com/sadikkuzu_mba) + [![tumblr-alt][tumblr-img]](http://sadikkuzu.mba) + ### Sahil - I am an undergraduate student. diff --git a/code/sadikkuzu.py b/code/sadikkuzu.py new file mode 100644 index 0000000..b8a2f43 --- /dev/null +++ b/code/sadikkuzu.py @@ -0,0 +1,23 @@ +## https://gist.github.com/sadikkuzu/af6a69d73f463b1b6b30aec15935dbc9 +# https://www.wikiwand.com/en/Happy_number +# http://mathworld.wolfram.com/HappyNumber.html + + +def square(x): + return int(x) * int(x) + + +def happy(number): + return sum(map(square, list(str(number)))) + + +def is_happy(number): + seen_numbers = set() + while number > 1 and (number not in seen_numbers): + seen_numbers.add(number) + number = happy(number) + return number == 1 + + +def is_happy2(n): # recursive + return (n == 1 or n > 4 and is_happy2(happy(n))) \ No newline at end of file