Cant into logic

So guys, im studying CS , but i really suck at programming(PHP, Java) .Sometimes i think i have learning disability or some shit. Cant even make assingments from college. Math is my worst enemy. What are my options? i mean should i focus on HTML,CSS and Javascript or something else? Is there some proffesion in IT that i dont need logical thinking and math? Thanks

Other urls found in this thread:

mathforum.org/dr.math/faq/faq.prime.num.html
jsfiddle.net/k6ntjr9b/
twitter.com/NSFWRedditGif

Just wait until you take discrete math

lel you just failed a math exam didn't you?

If you're too dumb for math then programming isn't for you. Consider a help desk job instead or Networking.

you mean like Sys admin ?

lol is this what cstards think hard math is?

and if you're too dumb for actual math then there is always programming

yes, helpdesk is a starting point

git gud fgt

well im trying to learn :) i guess its just my anxiety, that cant let me concentrate on the task , because when im trying to solve some problem in class my head always get interupted by lots of random thoughts :((

>thinking you need math to live off of programming

Read books if you get distracted , real ones or pdf on your phone , stay away from your pc and the room you usually stay in. A good book for java is head first java or C Programming: A Modern Approach , for C.

>A good book for java is head first java
ISHYGDDT

Name one better java book for retards , i'll wait.

thanks :) i am thinking that web dev route has the least math? anyway im just gonna try really hard in the upcoming years :) doesnt matter that i dont even know basic math sometimes :D

Give an example of what you'd consider difficult

"Create a doubly linked list"

well today at school i had to make program, for finding primal numbers from 5 to 100 and putting them into array and printing everything on screen, the language was PHP , it was fucking hard for me

You can't into truth tables?

You can't into deductive/inductive reasoning?

You can't do basic math?

>Primal Numbers
Prime*

did it in javascript but you can translate to PHP easily im sure

var primeNumbers = [1, 2]

for(var i = 3; i < 100; i++) {
for(var j = 1; j < primeNumbers.length; j++) {
if(i % primeNumbers[j] == 0) {
break;
}

if(j == primeNumbers.length - 1) {
primeNumbers[primeNumbers.length] = i;
}

}
}

console.log(primeNumbers);

>Is there some proffesion in IT that i dont need logical thinking and math? Thanks
Are you a woman?

Give me the quick rundown for the thought process here

Someone should make a programming language that does exactly what you say in words, and not some if's and true falses
like ''find me primal numbers''

>and if you're too dumb for actual math then there is always programming

The fuck, blame this kind of comments on shitty bootcamps , you can't do interesting shit without math. taking somebody else frameworks and just playing with them wont let you create something really new.

The reason for that kind of homeworks is to get into the process of converting mathematical expressions to code, otherwise you wont be able to understand more complex algorithms, for example try to read a IEEE level paper.

learn haskell, its one of the closes languages to the matematical one, the benefit of the imperative paradigms is that you can tell to the computer precisily what to do, functional and restriction oriented programming tries to find the solution but you can't control how it does.

//we start off KNOWING 1 and 2 are prime
var primeNumbers = [1, 2]

//here we LOOP through numbers 3 - 100 (we're starting at 3 because we already know 1 and 2 are prime)
for(var i = 3; i < 100; i++) {
//here, we loop through our array of prime numbers
for(var j = 1; j < primeNumbers.length; j++) {
//Modulus divide whatever number we're looping through, with whatever prime numbers we've found (excluding 1, because anything dividing by 1 can still be prime)
if(i % primeNumbers[j] == 0) {

//if a number DID divide evenly with a number we already have, then it can't be prime. Prime numbers can only be divided by 1 and itself
break;
}

//if we've looped through the array of prime numbers and it turns out nothing divided it
if(j == primeNumbers.length - 1) {
// we add it to our array
primeNumbers[primeNumbers.length] = i;
}

}
}

//lists all prime numbers
console.log(primeNumbers);


I'll continue in more depth in the following post

So, we already KNOW 1 and 2 are prime numbers. This is important for determining every other prime number, starting at 3

with "for(var i = 3; i < 100; i++)" we are literally going through every possible number between 3 and 100, figuring out which one is prime

The part I think you might be most confused on is:

"for(var j = 1; j < primeNumbers.length; j++) {
if(i % primeNumbers[j] == 0) {"

So let's explain that one in a bit more detail. the "var j = 1; j < primeNumbers.length" basically loops through every number that we've added to our array. But you're probably wondering /why would we loop through our array of prime numbers?/ The reason for this is because a prime number can ONLY be divided by 1 and itself. let's look at an example:

14 - NOT PRIME, but a multiple of TWO PRIMES, 2 and 7
21 - NOT PRIME, but a multiple of TWO PRIMES, 3 and 7
55 - NOT PRIME but a multiple of TWO PRIMES, 5 and 11
etc

all NON-PRIMES are a multiple of a regular PRIME in some form or another

so what we're basically saying is "if NONE of the PRIMES (excluding 1) that we've found can evenly divide this number, then it must also be prime"
then we add it to our array

This doesnt work for numbers higher than 10. Give a list of expected output and your programs actual output.

Expected output: mathforum.org/dr.math/faq/faq.prime.num.html

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,

My output:
jsfiddle.net/k6ntjr9b/

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

It's 100% correct

If you suck at math and are in CS, then yes. It's the hard part.

Same can't understand the logic even to save my life but I want to take a JS bootcamp to solve that

>1 is prime
No

1 is manually put in and has absolutely no effect on the code.

OP didn't explicitly say what definition of prime he was using, so i figured it wouldn't matter.

I was just being nitpicky, user, so that those who don't know any better (like OP) aren't lead astray

its all good :) thanks for the help , hope we all make it

i used to take some ADD meds before class (friend's desoxyn). helps me focus. also good for late night work, exams, etc.