Skip to main content
techie summer

the summer season has started, and what a great way to enjoy it than to start hacking (or coding, for the misinformed) on old projects, and new ones as well...

however, to the un-tech savvy people reading this blog, i'm sorry but i would have to get a little technical. first of, i'd like to start with a snippet of code, which i hope would be helpful to you and your endeavors.


#include <math.h>

int isprime(int n) {
int prime=1; /* assume that the number is prime */
int dlimit, dit;

if (n <= 3) /* the first 3 primes */
return prime;

if (!(n % 2)) /* if divisible by 2 (or even) */
prime = 0; /* it's not prime */

dlimit = (int) sqrt ( (double) n); /* result of sqrt is a double */

for (dit = 5; (dit <= dlimit) && (prime); dit+=2)
if (!(n % dit)) /* if divisible by odd numbers */
prime = 0; /* then it's not prime */

return prime;
}


this (as you might notice in the near future) will check whether a number is prime. in my estimation, the running time of this algorithm is O(n^1/2) or [oh of square root of n] where n is the number to be checked for primality.

i came up with this and a few more useful code snippets while i was thinking about and checking on my coding abilities the past few days.

now, i will need to brush up on my programming skills because i think i'm way behind of the pack, and knowing how to code is something, and writing code that actually works is another. i have to got both, but still more work is required. anyway, i hope i have time to do what i love most to do, which is think.

chill! =)

Comments

Popular posts from this blog

Appreciating Rizal...

Nope, this is not an academic post. More of a reflective and wrote-because-i-was-enlightened type post. Anyway, I just passed a paper on Rizal's notion of a nation according to Quibuyen (a local writer who devoted a book -- A Nation Aborted -- on his treatise on Rizal). Chapter 6 was an interesting read, and a definite eye opener. Rizal all of a sudden became interesting, especially to someone like me who could care less. It seems that most of what Rizal aims for and wrote about is still evident in today's Philippines as I see it. I wonder why I didn't get to appreciate Rizal and his work when I was still in high school -- might be the fault of the high school and the curriculum, or might be because I was still considerably immature then. I wasn't able to understand most of Rizal's writings though even if I got to reading them basically because they translated from Spanish to Filipino/Tagalog. I don't have problems with Tagalog, until you put it in writing. I

From FOMO to JOMO

Until very recently I believed that I needed to be on top of the latest news and happenings not only in my field (computer science and software engineering) but also in as many things as I can be on top of. This meant subscribing to all sorts of magazines, newsletters, YouTube channels, Twitch streamers, watching TV and live sport events, etc. — I was on top of a lot of the latest happenings, trends, news, interesting developments. I was having fun and I felt busy. What I did not feel was particularly effective nor productive. I felt like I was consuming so much information with the thought that it might be useful someday. When I was younger this wouldn’t have been an issue but I realised that ever since I’ve started taking stock of what I’ve been spending my time on, that a lot of it I’ve been spending just staying on top of things that I really didn’t need to be on top of. This article is about some of the realisations I’ve made in the course of exploring this issue of “FOMO” or

Keeping a work log

I have been keeping a journal for my personal life with some regularity for the good part of 4 years. The difference between my earlier attempts at journaling before four years ago is the regularity and the structure. I started with a very structured and regimented journal (doing it everyday with prompts and blanks to fill), to a ruled journal notebook, then a plain notebook (no rules nor grids in the pages), and then settling on a dot-grid notebook. This allows me to doodle and write free-form to help me commit thoughts and observations of my day but it was mostly for archival and looking back to "feel good" or reminisce (also to sum up a month, a year, etc.) The approach helps a lot with self-improvement in terms of my mental health and my reflection to see where I was a specific amount of time ago and whenever I was reading it again. In a previous post I wrote about keeping a work log, and I realised I only mentioned that in passing. In this post I detail the structure of