A number is said to be 'sunny' when, 1 added to that number, the square root of it becomes a whole number...
Chat with our AI personalities
class Sunny { void accept(int n) { int n1=n+1; double x=Math.sqrt(n1); if((int)x==x) System.out.println("sunny number"); else System.out.println("not a sunny number"); } }
A "sunny number" is a whole number, n, such that the square root of n+1 is a whole number. #include<stdio.h> #include<math.h> // for sqrt bool is_sunny (int n) { int s = sqrt (++n); return s*s==n; } int main (void) { // print sunny numbers in the half-closed range [0:100) for (int n=0; n<100; ++n) { if (is_sunny (n)) { printf ("%d is a sunny number\n"); } else { printf ("%d is not a sunny number\n"); } } return 0; }
Sunny
a negative number
A number that ends with 7 and is also divisible by 7 is called buzz number.