# Author Archives: victor

## How to translate Shona to English.

Shona to English translation is not easy. So is any translation, because no language is one to one with another language no matter how unrelated or related they are. Shona for one, does not share any roots with English, other … Continue reading

## Generating n prime numbers in JavaScript

/** * Prime number * parameter n is an integer * Generate n prime numbers */ var primeList=[2]; //seed function prime(n) { n += 1; for (var k = 0; k < primeList.length; k++) { if((n%primeList[k])==0) return prime(n); } primeList.push(n); … Continue reading

## Get fibonacci numbers using JavaScript function

//Returns a Fibonnaci number//@param n is an integerfunction fibonacci(n){ if(n < 0) { return 0; } else if(n

## Fibonacci numbers : Python

def fibonacci(n): “”” Returns a fibonacci number Author: http://www.victorbyte.net “”” if (n == 1) or (n==2): return 1; elif n >= 3: return fibonacci(n – 1)+fibonacci(n-2);

## Find the factorial : Python

def factorial(n): """ Returns the factorial of an integer Author: http://www.victorbyte.net """ if n == 0: return 1; elif n > 0: return n * factorial(n – 1);

## Remove duplicate characters: python

Python is a great language for text formatting. The trivial functions below are not fully representative of the things one can do in Python, however for a beginner they are sufficient. For further reading I suggest one looks at Python's … Continue reading

## Check for duplicate characters : Python

def hasDuplicate(str_var): “”” Checks for repeated characters Author: http://www.victorbyte.net returns Boolean value “”” for i in range (0, len(str_var)): for j in range( i + 1, len(str_var)): if str_var[i].lower() == str_var[j].lower(): return True; return False;

## Check for repeated characters: csharp

/// Checks for repeated characters /// Author: http://www.victorbyte.net /// returns Boolean value static bool hasDuplicate(string str) { for (int i = 0; i < str.Length; i++) { for (int j = i + 1; j < str.Length; j++) { if … Continue reading

## Greatest Common Divisor : Java

/** * Gets GCD between two positive integers. * source: http://www.victorbyte.net * Returns int value */ public static int getGCD(int numA, int numB) { if(numA < numB) { int temp = numA; numA = numB; numB = temp; } if( … Continue reading

## Using Python to visualize the div, mod and remainder of a number.

def divTheory(a,b): n = a; d = b; q = n // d; r = n % d; print(n,” = number n”,d,” = divisor n”,q,” = quotient n”,r, ” = remaindern”);