+ 18

๐ŸŒž๐ŸŒž๐ŸŒž๐ŸŒžCHALLENGE ๐ŸŒž๐ŸŒž๐ŸŒž๐ŸŒž

Write a program to check whether a number is Sunny number or not. A number n is said to be sunny number if square root of(n+1) is an integer. e.g. 8 is a sunny number because sq.root of (8+1)is 3 ,which is an integer.

17th Mar 2018, 6:46 PM
Neelarghya Kundu
Neelarghya Kundu - avatar
20 Answers
22nd Apr 2018, 8:18 AM
MeanMachine
MeanMachine - avatar
+ 18
(Math.sqrt(n+1)%1.0==0.0) //bcz Integer%1 will be 0 only โ˜บ
17th Mar 2018, 7:08 PM
Gaurav Agrawal
Gaurav Agrawal - avatar
+ 16
const isSunny = n => Math.sqrt(n+1) === parseInt(Math.sqrt(n+1)) ? true : false;
17th Mar 2018, 6:56 PM
Maz
Maz - avatar
17th Mar 2018, 7:28 PM
Baraa AB
Baraa AB - avatar
17th Mar 2018, 11:20 PM
Med Arezki
Med Arezki - avatar
+ 12
https://code.sololearn.com/cRhs7z3sIdj2/?ref=app ๐ŸŒž๐ŸŒž
17th Mar 2018, 7:04 PM
Neelarghya Kundu
Neelarghya Kundu - avatar
17th Mar 2018, 7:57 PM
Baraa AB
Baraa AB - avatar
+ 11
yes I will do that
17th Mar 2018, 6:50 PM
Neelarghya Kundu
Neelarghya Kundu - avatar
+ 10
Remember that you can submit this as an assignment using Lesson Factory. :>
17th Mar 2018, 6:50 PM
Baraa AB
Baraa AB - avatar
17th Mar 2018, 10:04 PM
Tomรกs Badenes
Tomรกs Badenes - avatar
18th Mar 2018, 4:00 PM
๐Ÿ™evil octopus
๐Ÿ™evil octopus - avatar
17th Mar 2018, 11:59 PM
ฦ’red
ฦ’red - avatar
+ 6
https://code.sololearn.com/cVYBCM2qxIQF/#py Also prints out all the Sunny numbers between 0 to 100 #python
18th Mar 2018, 7:20 AM
Pallav Gurung
+ 6
C# Func<int, bool> IsSunny = i => (Math.Sqrt(i + 1) == Convert.ToInt32(Math.Sqrt(i + 1))) ? true : false;
18th Mar 2018, 2:48 PM
Cool Codin
Cool Codin - avatar
+ 4
This is my solution in java: https://code.sololearn.com/c6tlpWzXr9le/#java Of course, all it really is is just: if(Math.sqrt(n+1)%1.0==0.0){ ... it's sunny } else{ ... it's not sunny } Also, how does this make the number "sunny?"
18th Mar 2018, 12:57 PM
Sheldon Duncan
Sheldon Duncan - avatar
19th Mar 2018, 9:55 PM
Coder++
Coder++ - avatar
+ 3
https://code.sololearn.com/cae54M5tf88u/?ref=app https://code.sololearn.com/ccSa117dGNvA/?ref=app
18th Mar 2018, 11:53 AM
Abhimanyu Gupta
Abhimanyu Gupta - avatar