CAN YOU HELP ME GUYS? COZ ITS TO BE SUBMITTED TODAY 11:59AM EST TIME

QUIZ WEEK 1

1. Suppose you are given 1 cent on day 1 and on day 2 you are
given twice as much. If each day you are given twice as much
as on the previous day, then on day 10, how many pennies will
you receive? Can you program that? (HINT: use loops)

Other urls found in this thread:

github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition
twitter.com/NSFWRedditImage

thank me later.

sum(map(lambda x: x * 2, range(1, 11)))

class p{public static void main(String[]a){System.out.println(1

Math.pow(2, n)-1

Add a while(false) {} if you need a loop.

Thank you for what? Being wrong? The question is how many pennies will you receive on day 10, not how many pennies you'll have in total on day 10.

I don't think that's Java =_=

WE ENEED TO USE LOOPS

I dont know

Should be easy in Python, like 5-6 lines or something.

receivedPennies :: Integer -> Integer
receivedPennies n = foldr (+) $ iterate (*2) [1..n]

Why do you need to use loops to calculate 2^9…?

Why are you guys spoonfeeding this retard? This is literally some of the simplest shit I've seen.

This.

Lmao this faggot

Beautiful.

>had to take class on recursion for Uni
Makes you open up your mind desu familia. Every problem you would solve with iteration seems so easy if you think about solving it with recursion.

int result = 1;
for(int i = 0; i < 10; i++) {
i*=2;
}
System.out.println("Result: " + result);

I'm doing this because I don't want you to succeed

Why don't you just bend over so Pajeet can fuck you

literally
return 1024;

oops: it's results*=2, not that other shit

>1024
see me after class.

THANK YOU!!!
Can you help me with these one to?

"Fizz buzz is a game where players take turns to count incrementally, replacing any number divisible by three with the word "fizz", and any number divisible by five with the word "buzz".
Simulate this game for numbers 1 to 100.

It is however one of the very best examples of why it is important to understand mathematics and algorithms before reaching for the keyboard and hack out loops compulsively.

It is also a good example on what happens with outsourcing.

Also it explains why Visicalc could be made in 48 KB (yes - kilo byte) RAM while today you cannot do anything before the CPU chomps a few gigabytes RAM.

Read - remember - weep.

Stop being such a fucking bitch

Ok, I can do java

_.range(1, 11).map((x) => x*2).reduce((a, b) => a + b, 0)

i % 3 will check if int i is divisible by 3 if it equals to 0

>Also it explains why Visicalc could be made in 48 KB (yes - kilo byte) RAM while today you cannot do anything before the CPU chomps a few gigabytes RAM.
no it doesn't you fucking idiot.

What does '%' do? My teacher dont really explain it well.

>thinks a loop with multiplication is not far bigger than 10 arithmetic shifts of a 16 bit value.

It gives you your percentage in the course.

Go ahead, type 3%3 into google and see what you get.

No, it isn't dumb fuck.

A loop to calculate 2^n would have be O(1) when regarding space. For each iteration you would only need to know
1) n-m, where m is the amount of iterations that has already occurred
2) the number being multiplied by 2

public static void main(String... args) {
System.out.println(""+Math.pow(2,9));
}

Forgot to mention
Read the beginning of SICP, it goes into this within the first chapter.

Fuck man, I also need help with this assignment guys.

Suppose you are given 10 dragon dildos and each day you stick 1 inside your anus, then on day 5, how much dragon dildos would have disappeared inside your anus? (HINT: Use lube)

ok user. that sounds like a O(5 days) problem. I'll be back in a week with a solution.

Are you seriously denying assembly code for 10 shifts is smaller than the preposterous loops!?

Have you ever programmed in assembly?

total = 1
loop from 1 to 10
total *= 2 each time


if you still need help with this you have no chance

>What does '%' do? My teacher dont really explain it well.

It's called the modulo.

It does division and then displays only the remainder.

Uhhh my teacher said it was the percent sign. We are in excelerated 4th year.

function howmanypenis() {
myaray = [1, 2, 4, 8, 16, 32, 65, 128, 256, 512]
]

for (var o = 9; o < 10; o++) {
return 512;
}
}

// meet me after class, prof ;3c
console.log(512);

This fizzbuzz thingy has been solved before by what I guess is a student going to the same school as you. You can find his solution here:

github.com/EnterpriseQualityCoding/FizzBuzzEnterpriseEdition

int total = 1024;
int current = 0;
while(current != total) current++;
//there you go senpai :^)

How did people pass programming classes without help from the internet?

Before the internet, only the children of programmers, computer scientists, mathematicians and physicists learned to program. In other words, only smart people programmed.

If dubs OP sends this as his answer.

Dubs demand

You definitely came to the right place.