while testing our app Easy Recharge, Version two, i saw this weird bug.
##Information
- Android version: 4.1.1
- Sim: Grameen Phone
#!/usr/bin/env python | |
# beta | |
# Lisence Under GPL2 | |
# Author: S.Mahbub-Uz-Zaman | |
import fnmatch | |
import os | |
def count_lines(filePath): |
// Author Shouro and Mahbub | |
// 24 February, 2014 | |
alias লিস্ট='ls' | |
alias ঢুকি='cd' | |
alias দেখ='vim' | |
alias কপি='cp' | |
alias মুছ='rm' | |
alias পুস্তিকাবানাও='mkdir' |
// Author: Mahbub | |
// http://mahbubzaman.wordpress.com/2013/10/24/android-time-class/ | |
/* | |
http://developer.android.com/reference/android/text/format/Time.html | |
just provide the month, year and day and get previous dates | |
Since Time class does not provides months and day name, you have to do that by yourself | |
*/ |
while testing our app Easy Recharge, Version two, i saw this weird bug.
##Information
List git gist
This script will print the output in HTML format on stdout. Console command
$ python list_your_gitgist.py > out.html
<!-- Author: Mahbub --> | |
<h1 id="prime">2</h1> | |
<p>is a prime number</p> | |
<!-- Randomly Generates primes from first 100 --> | |
<script> | |
var primes=[-1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163 ,167, 173, 179, 181, 191, 193, 197, 199, 211, 223, 227, 229, 233, 239, 241, 251, 257, 263, 269, 271, 277, 281, 283, 293, 307, 311, 313, 317, 331, 337, 347, 349, 353, 359, 367, 373, 379, 383, 389, 397, 401, 409, 419, 421, 431, 433, 439, 443, 449, 457, 461, 463, 467, 479, 487, 491, 499, 503, 509, 521, 523, 541]; | |
var index = Math.floor((Math.random() * (primes.length - 1)) + 1); | |
if (index >= 1 && index <= (primes.length - 1)) | |
document.getElementById("prime").innerHTML = primes[index]; |
A number is a prime number if that number has precisely two distinct divisors, one and itself. First ten prime numbers are
2, 3, 5, 7, 11, 13, 17, 19, 23, 29
So, if we can find that N has two divisors than it’s a prime number else not, this is actually brute force approach and the complexity is O (N). How we do that, starting from 1 to N we have check if N is divisible by 1, 2, 3, ….., N each time it divide we increment our divisor count by one and at the end we will check if the divisor count is 2 or not.
Can we do better, yes we can. Look carefully the only even prime is 2. If we add an if condition that if the number is 2 return true else false if the number is even, because other even numbers can’t not be a prime number. For even numbers the complexity becomes O (1). So what about odd numbers? How can we improve that? We can reduce the complexity for odd number O (N / 2). See we don’t need to divide by even numbers because the Number N is an odd number, so it will never be divide by an even number. So
// Author: Mahbub | |
// http://mahbubzaman.wordpress.com/2012/06/21/count-the-unique-character-in-a-string/ | |
/* | |
input | |
“aaaaaa” | |
“aaa aaa” | |
“abcdeabcde” | |
“YESyes” | |
output |