Tag: Python Tutorial

Prime Number Generator (6n + 1 or 6n – 1)

Prime Number Generator (6n + 1 or 6n - 1) This generator is like most where it brute forces an integer: it see whether the integer is divisible by any of the primes; if so, then it's not a prime and vice versa. This though only compares values 6n + 1 and 6n - 1 starting with n as 1 as … Continue reading Prime Number Generator (6n + 1 or 6n – 1)

Advertisements

Collatz Conjecture Meet of 2 Numbers in python

def first_collatz(n, visited): counter = 0 while n > 1: counter += 1 n = 3 * n + 1 if n & 1 else n >> 1 if n not in visited: visited[n] = counter def secondd_collatz(n, other): counter = 0 if n not in other: while n > 1: counter += 1 n … Continue reading Collatz Conjecture Meet of 2 Numbers in python

Simple budget program in python

I've decided to start working on a budget application for the purposes of enhancing my Python skills. In its current form this program takes given expenses and income and tells the user whether they have a surplus, a deficit, or if they are breaking even. Example: import os import sys class Application(): def __init__(self): self.income … Continue reading Simple budget program in python