Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //Check if there is a natural number i
- //by which t can be divided without rest
- //This code should only executed if it has been determined above that ((t - 1) % 3 == 0) is false
- int matchFound=0;
- int i=1;
- while (i*i <= t) { //Go through all natural numbers from 1 onwards
- //until i gets "too large"
- if (i*i == t) matchFound=1; //If there is a natural number i that multiplied with itself is t,
- //t has an integer square root and is part of the function t=n²
- i++; //Don't forget to actually count up!
- }
- return matchFound; //returns 1 if t is part of the function t=n², 0 if not
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement