Tag Archive for Appelbaum

America, Get Rid of The Penny!

It’s common knowledge by now (I hope) that a penny (1 cent) costs more than 1 cent to make. With that being said… WHY DOES AMERICA STILL PRODUCE THEM??

pennies One of my favorite youtubers John Green (who’s also an amazing writer) had the opportunity to hang out with President Obama on Google+ today and he asked him the same exact question. The discussion about the penny prompted this article on Yahoo! which quoted most of the important parts of President Obamas answer like “It’s one of those things where I think people get attached emotionally to the way things have been,” the president said. “We remember our piggy banks and counting out all the pennies and then taking them and getting a dollar bill or a couple of dollars.” (More quotes and detail in the article and video of the hangout – links above-).

To be honest, the United States is holding on to too many things because they’re “attached emotionally” to them, to a point where common sense doesn’t matter. After all, the two biggest concerns I hear with regards to getting rid of the penny are: 1) “will prices of products be rounded up or down?” and 2) “The ‘change problems’ that says: if you owe $2.97 and paid $3.00, do you get 5 cents back or no change at all?” While both concerns aren’t something to be ashamed to ask, after all I believe that it would be nice to have an answer for these questions if the people truly wanted them… but they don’t. These “concerns” aren’t really that critical to the American population… Most people don’t care for change. Just today I found over 8 cents in pennies and nickles on the street… These seem like a couple of excuses more than actual concerns. So I decided instead of trying to answer these questions rationally, to depict a few scenarios in which these problems arise in some shape or form and provide a reaction to these scenarios in similar ways to the ways most people would handle these scenarios:

Read more

Project Euler Problem 6 Solution – Sum Square Difference

Sum Square Difference also known as problem 6 is very straight forward math… (A) calculate the summation of the numbers squared, and (B)then the square of the summation… then subtract A from B… my solution for this problem is below in C++

#include <iostream>
#include <string>
#include <sstream>

using namespace std;


int main(){
    int sumfirsthundred = 0;
    int squarefirsthundred = 0;
    int sumfirsthundredsqr = 0;
    for(int i = 1; i < 101; i++){
        sumfirsthundred = sumfirsthundred + i;
        squarefirsthundred = squarefirsthundred + (i*i);
    }
    sumfirsthundredsqr = sumfirsthundred * sumfirsthundred;
    cout << sumfirsthundredsqr - squarefirsthundred << "n";
    std::cout << "Press ENTER to continue...";
    std::cin.ignore( std::numeric_limits<std::streamsize>::max(), 'n' );
    return 0;
}
									

 

Stock Market and me…

For quite a while I’ve been looking into the stock market, figuring out how it works, what to do, etc. Unlike all the “pros” I don’t have a stocks analyzer (yet), but based on my personal knowledge of certain companies, lots of research, following trends, etc. I’ve been doing very good in the market. Last year I saw a profit of 89%! which is pretty cool. I did suffer for quite a while, most of the year around terrifying negatives, but at the end of the day, I almost doubled my money.

Unfortunately, I am still a college student which means I don’t make enough money to even sustain myself… And every time I see a stock that I “would’ve bought if I had money” go up 20-25%, it pisses me off. So… I figured I’d write about it. I am sure no one is reading this, and that as a “rookie”, unknown college student that doesn’t have access to statistics and data, my word isn’t worth a dime… but hopefully after a few articles of suggestions that go unheard and profits are made, maybe I’ll either be taken more seriously OR find a job to spend my own money on it.

Stay tuned, any day can come a new investing post… Cheers!

Project Euler Problem 7 Solution – 10001st Prime

10001st Prime is another prime calculating problem… nothing hard. my solution is below and written in C++.

#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int isPrime(int number){
int count=0;
for(int a = 1; a<=number ;a++)
{
if(number % a == 0)
count++;
}
if(count == 2)
return number;
return 0;
}

int main(){
int primecount = 0;
int num = 1;
int prime = 0;
bool working = true;
while(primecount != 10001){
prime = isPrime(num);
num++;
if(prime > 0){
primecount++;
}
}

cout << prime <<"n";
std::cout << "Press ENTER to continue...";
std::cin.ignore( std::numeric_limits<std::streamsize>::max(), 'n' );
return 0;
}

 
									

Project Euler Problem 14 Solution – Longest Collatz sequence

Longest Collatz sequence is a very cool problem which I first encountered (requiring different things, but method was the same) when I started learning C++. The problem states that for any set of positive integers you do the following:

n → n/2 (n is even)
n → 3n + 1 (n is odd)

and that eventually, any number will end up at 1. the problem requires us to count how many numbers are in the chain between n and 1… the solution to this classic project Euler problem is below in Java.

 

/*
 * Author: Gal Appelbaum
 * www.galappelbaum.com
 */

public class p14 {

    public static void main(String[] args){
        int longestChain = 0;
        int finalNumber = 0;
        int count = 1;
        double currentNumber = 0;
        for(int i = 2; i < 1000000; i++){
            currentNumber = i;
            while(currentNumber != 1){
                if(currentNumber % 2 == 0)
                    currentNumber = currentNumber/2;
                else
                    currentNumber = 3*currentNumber + 1;
                count++;
            }
            if(count > longestChain){
                longestChain = count;
                finalNumber = i;
            }
            count = 0;
            System.out.println(i);
        }
        System.out.println(finalNumber);
    }
}