+ 1
Pow (Swift)
var a = 2, b = 3 //(a+4b)(a–3b)+a^2 var res = (a + (4 * b)) * (a - (3 * b)) + pow(Double(a),2) print(res) //I do not know how to square, for some reason the answer is not displayed
9 Respostas
+ 3
This one
import Foundation
var a = 2, b = 3
//(a+4b)(a–3b)+a^2
var res = (a + 4 * b) * (a - 3 * b) + Int(pow(Double(a),2))
print(res)
Becomes - 94
Don't know if you need a Integer Result, or a Double Result
+ 1
Wow , thank you very much!!!!🎉
0
Try: import Foundation
I've tested this, and it's running
import Foundation
var res = pow(5.0,2)
print(res)
https://stackoverflow.com/questions/24012511/mathematical-functions-in-swift
0
And why here 5.0?
0
Only for testing. I don't know anything about Swift
0
But this is also working:
import Foundation
var a = 5
var res = pow(Double(a), 2)
print(res)
0
Yes it works, but for some reason it doesn't work for me in the equation (
0
Hmm, looks like another issue. 🤔
0
Viktor Kizera Your'e welcome.